.then(function() {
        if(dest && target) {
            //add target to fetchArgs Array
            fetchArgs.push(target);
        
            //append node_modules to dest if it doesn't come included
            if (path.basename(dest) !== 'node_modules') {
            dest = path.resolve(path.join(dest, 'node_modules'));
            }
        
            //create dest if it doesn't exist
            if(!fs.existsSync(dest)) {
                shell.mkdir('-p', dest);         
            } 

        } else return Q.reject(new CordovaError('Need to supply a target and destination'));

        //set the directory where npm install will be run
        opts.cwd = dest;

        //if user added --save flag, pass it to npm install command
        if(opts.save) {
            events.emit('verbose', 'saving');
            fetchArgs.push('--save'); 
        } 
    

        //Grab json object of installed modules before npm install
        return depls(dest);
    })
Esempio n. 2
0
        .then(function () {
            if (dest && target) {
                // add target to fetchArgs Array
                fetchArgs.push(target);

                // append node_modules to nodeModulesDir if it doesn't come included
                if (path.basename(dest) !== 'node_modules') {
                    nodeModulesDir = path.resolve(path.join(dest, 'node_modules'));
                }
                // create node_modules if it doesn't exist
                if (!fs.existsSync(nodeModulesDir)) {
                    shell.mkdir('-p', nodeModulesDir);
                }
            } else return Q.reject(new CordovaError('Need to supply a target and destination'));

            // set the directory where npm install will be run
            opts.cwd = dest;
            // npm should use production by default when install is npm run

            if ((opts.production) || (opts.production === undefined)) {
                fetchArgs.push('--production');
                opts.production = true;
            }

            // if user added --save flag, pass it to npm install command
      if (packageManager === 'npm') {
            if (opts.save_exact) {
                events.emit('verbose', 'saving exact');
                fetchArgs.push('--save-exact');
            } else if (opts.save) {
                events.emit('verbose', 'saving');
                fetchArgs.push('--save');
            } else {
                fetchArgs.push('--no-save');
            }
      }
            // Grab json object of installed modules before npm install
            return depls(nodeModulesDir);
        })
 .then(function(output) {
     //Grab object of installed modules after npm install
     return depls(dest);
 })