(function () {
    'use strict';

    module.exports = function () {
        var glob = require("glob"),
            fs = require('fs-extra'),
            path = require('path');

        /**
         * Process all the mocks.
         * @param {string} src The directory containing the mocks.
         *
         * #1 iterate over each json file
         * #2 add the content to the mocks collection
         */
        function processMocks(src) {
            var mocks = [];
            // #1
            glob.sync('**/*.json', {cwd: src, root: '/'}).forEach(function (file) {
                // #2
                mocks.push(fs.readJsonSync(src + path.sep + file, {throws: true}));
            });
            return mocks;
        }

        /**
         * Generate the mocking interface by processing all mocks.
         * @param {string} outputDir The output directory.
         *
         * #1 copy the interface to the output directory
         * #2 copy the dependencies to the output directory
         */
        function generateMockingInterface(outputDir) {
            // #1
            var templateDir = path.join(path.resolve(__dirname, '..'),'/templates/interface');
            glob.sync('**/*', {cwd: templateDir, root: '/'}).forEach(function(file) {
                fs.copySync(templateDir + path.sep + file, outputDir + path.sep + file);
            });

            var nodeModulesDir = path.join(process.cwd(), '/node_modules');
            fs.copySync(nodeModulesDir + path.sep + 'angular' + path.sep + 'angular.min.js', outputDir + path.sep + 'js' + path.sep + 'angular.min.js');
            fs.copySync(nodeModulesDir + path.sep + 'angular-resource' + path.sep + 'angular-resource.min.js', outputDir + path.sep + 'js' + path.sep + 'angular-resource.min.js');
        }

        /**
         * Copy the protractor.mock.js file to the output dir.
         * @param {string} outputDir The output directory.
         *
         * #1 update the template with the module name
         * #2 write the template to file
         */
        function generateProtractorMock(outputDir) {
            fs.copySync(path.resolve(__dirname, '..') + '/templates/protractor.mock.js', outputDir + path.sep +'protractor.mock.js');
        }

        return {
            processMocks: processMocks,
            generateMockingInterface: generateMockingInterface,
            generateProtractorMock: generateProtractorMock
        };
    };
})();
@@ -170,16 +170,74 @@
 ('path')
+,%0A            ngApimockCwd = path.resolve(__dirname, '..')
 ;%0A%0A     
@@ -1122,34 +1122,16 @@
 tDir) %7B%0A
-            // #1%0A
         
@@ -1166,62 +1166,140 @@
 oin(
-path.resolve(__dirname, '..'),'/templates/interface');
+ngApimockCwd, '/templates/interface'),%0A                nodeModulesDir = path.join(ngApimockCwd, '/node_modules');%0A            // #1%0A
 %0A   
@@ -1372,16 +1372,17 @@
 function
+ 
 (file) %7B
@@ -1492,84 +1492,8 @@
 );%0A%0A
-            var nodeModulesDir = path.join(process.cwd(), '/node_modules');%0A
     
@@ -2166,37 +2166,20 @@
 ync(
-path.resolve(__dirname, '..')
+ngApimockCwd
  + '
@@ -2232,16 +2232,17 @@
 th.sep +
+ 
 'protrac

fix incorrect path to angular