cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From audre...@apache.org
Subject [06/18] cordova-lib git commit: CB-12895 : ran eslint --fix on cordova-lib
Date Fri, 28 Jul 2017 18:26:37 GMT
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/platform/check.js
----------------------------------------------------------------------
diff --git a/src/cordova/platform/check.js b/src/cordova/platform/check.js
index 20a13c9..e190f37 100644
--- a/src/cordova/platform/check.js
+++ b/src/cordova/platform/check.js
@@ -36,8 +36,8 @@ function check (hooksRunner, projectRoot) {
     var result = Q.defer();
     var updateCordova = Q.defer();
     superspawn.spawn('npm',
-                     ['--loglevel=silent', '--json', 'outdated', 'cordova-lib'],
-                     {cwd: path.dirname(require.main.filename)}
+        ['--loglevel=silent', '--json', 'outdated', 'cordova-lib'],
+        {cwd: path.dirname(require.main.filename)}
     ).then(function (output) {
         var vers;
         try {
@@ -56,100 +56,96 @@ function check (hooksRunner, projectRoot) {
         updateCordova.resolve();
     });
     require('../cordova').create(scratch)
-    .then(function () {
-        var h = new HooksRunner(scratch);
-        // Acquire the version number of each platform we have installed, and output that too.
-        Q.all(platforms_on_fs.map(function (p) {
-            var d = Q.defer();
-            var d_avail = Q.defer();
-            var d_cur = Q.defer();
-            require('./index').add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
-            .then(function () {
-                // TODO: couldnt we return the promise on the next line, and then
-                // unindent all the promise handlers one level?
-                superspawn.maybeSpawn(path.join(scratch, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
-                .then(function (avail) {
-                    if (!avail) {
-                        /* Platform version script was silent, we can't work with this */
-                        d_avail.resolve('version-empty');
-                    } else {
-                        d_avail.resolve(avail);
-                    }
-                })
-                .catch(function () {
-                    /* Platform version script failed, we can't work with this */
-                    d_avail.resolve('version-failed');
-                });
-            }).catch(function () {
-                /* If a platform doesn't install, then we can't realistically suggest updating */
-                d_avail.resolve('install-failed');
-            });
+        .then(function () {
+            var h = new HooksRunner(scratch);
+            // Acquire the version number of each platform we have installed, and output that too.
+            Q.all(platforms_on_fs.map(function (p) {
+                var d = Q.defer();
+                var d_avail = Q.defer();
+                var d_cur = Q.defer();
+                require('./index').add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
+                    .then(function () {
+                        // TODO: couldnt we return the promise on the next line, and then
+                        // unindent all the promise handlers one level?
+                        superspawn.maybeSpawn(path.join(scratch, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
+                            .then(function (avail) {
+                                if (!avail) {
+                                    /* Platform version script was silent, we can't work with this */
+                                    d_avail.resolve('version-empty');
+                                } else {
+                                    d_avail.resolve(avail);
+                                }
+                            })
+                            .catch(function () {
+                                /* Platform version script failed, we can't work with this */
+                                d_avail.resolve('version-failed');
+                            });
+                    }).catch(function () {
+                        /* If a platform doesn't install, then we can't realistically suggest updating */
+                        d_avail.resolve('install-failed');
+                    });
+
+                superspawn.maybeSpawn(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
+                    .then(function (v) {
+                        d_cur.resolve(v || '');
+                    }).catch(function () {
+                        d_cur.resolve('broken');
+                    });
 
-            superspawn.maybeSpawn(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
-            .then(function (v) {
-                d_cur.resolve(v || '');
-            }).catch(function () {
-                d_cur.resolve('broken');
-            });
+                Q.all([d_avail.promise, d_cur.promise]).spread(function (avail, v) {
+                    var m;
+                    var prefix = p + ' @ ' + (v || 'unknown');
+                    switch (avail) {
+                    case 'install-failed':
+                        m = prefix + '; current did not install, and thus its version cannot be determined';
+                        break;
+                    case 'version-failed':
+                        m = prefix + '; current version script failed, and thus its version cannot be determined';
+                        break;
+                    case 'version-empty':
+                        m = prefix + '; current version script failed to return a version, and thus its version cannot be determined';
+                        break;
+                    default:
+                        if (!v || v === 'broken' || semver.gt(avail, v)) {
+                            m = prefix + ' could be updated to: ' + avail;
+                        }
+                    }
+                    if (m) {
+                        platformsText.push(m);
+                    }
+                    d.resolve(m);
+                }).catch(function () {
+                    d.resolve(p + ' ?');
+                }).done();
 
-            Q.all([d_avail.promise, d_cur.promise]).spread(function (avail, v) {
-                var m;
-                var prefix = p + ' @ ' + (v || 'unknown');
-                switch (avail) {
-                case 'install-failed':
-                    m = prefix + '; current did not install, and thus its version cannot be determined';
-                    break;
-                case 'version-failed':
-                    m = prefix + '; current version script failed, and thus its version cannot be determined';
-                    break;
-                case 'version-empty':
-                    m = prefix + '; current version script failed to return a version, and thus its version cannot be determined';
-                    break;
-                default:
-                    if (!v || v === 'broken' || semver.gt(avail, v)) {
-                        m = prefix + ' could be updated to: ' + avail;
+                return d.promise;
+            })).then(function () {
+                var results = '';
+                var resultQ = Q.defer();
+                events._events = listeners;
+                shell.rm('-rf', scratch);
+                updateCordova.promise.then(function (versions) {
+                    var message = '';
+                    if (versions && semver.gt(versions[0], versions[1])) {
+                        message = 'An update of cordova is available: ' + versions[0] + '\n';
                     }
+                    resultQ.promise.then(function (output) {
+                        var results = message + output;
+                        events.emit('results', results);
+                        result.resolve();
+                    });
+                });
+                if (platformsText) {
+                    results = platformsText.filter(function (p) { return !!p; }).sort().join('\n');
                 }
-                if (m) {
-                    platformsText.push(m);
+                if (!results) {
+                    results = 'No platforms can be updated at this time.';
                 }
-                d.resolve(m);
-            })
-            .catch(function () {
-                d.resolve(p + ' ?');
-            })
-            .done();
-
-            return d.promise;
-        })).then(function () {
-            var results = '';
-            var resultQ = Q.defer();
+                resultQ.resolve(results);
+            }).done();
+        }).catch(function () {
             events._events = listeners;
             shell.rm('-rf', scratch);
-            updateCordova.promise.then(function (versions) {
-                var message = '';
-                if (versions && semver.gt(versions[0], versions[1])) {
-                    message = 'An update of cordova is available: ' + versions[0] + '\n';
-                }
-                resultQ.promise.then(function (output) {
-                    var results = message + output;
-                    events.emit('results', results);
-                    result.resolve();
-                });
-            });
-            if (platformsText) {
-                results = platformsText.filter(function (p) { return !!p; }).sort().join('\n');
-            }
-            if (!results) {
-                results = 'No platforms can be updated at this time.';
-            }
-            resultQ.resolve(results);
-        })
-        .done();
-    }).catch(function () {
-        events._events = listeners;
-        shell.rm('-rf', scratch);
-    })
-    .done();
+        }).done();
     return result.promise;
 }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/platform/list.js
----------------------------------------------------------------------
diff --git a/src/cordova/platform/list.js b/src/cordova/platform/list.js
index d7c2d4e..edd7d6c 100644
--- a/src/cordova/platform/list.js
+++ b/src/cordova/platform/list.js
@@ -24,33 +24,33 @@ module.exports.addDeprecatedInformationToPlatforms = addDeprecatedInformationToP
 
 function list (hooksRunner, projectRoot, opts) {
     return hooksRunner.fire('before_platform_ls', opts)
-    .then(function () {
-        return cordova_util.getInstalledPlatformsWithVersions(projectRoot);
-    }).then(function (platformMap) {
-        var platformsText = [];
-        for (var plat in platformMap) {
-            platformsText.push(platformMap[plat] ? plat + ' ' + platformMap[plat] : plat);
-        }
+        .then(function () {
+            return cordova_util.getInstalledPlatformsWithVersions(projectRoot);
+        }).then(function (platformMap) {
+            var platformsText = [];
+            for (var plat in platformMap) {
+                platformsText.push(platformMap[plat] ? plat + ' ' + platformMap[plat] : plat);
+            }
 
-        platformsText = addDeprecatedInformationToPlatforms(platformsText);
-        var results = 'Installed platforms:\n  ' + platformsText.sort().join('\n  ') + '\n';
-        var available = Object.keys(platforms).filter(cordova_util.hostSupports);
+            platformsText = addDeprecatedInformationToPlatforms(platformsText);
+            var results = 'Installed platforms:\n  ' + platformsText.sort().join('\n  ') + '\n';
+            var available = Object.keys(platforms).filter(cordova_util.hostSupports);
 
-        available = available.filter(function (p) {
-            return !platformMap[p]; // Only those not already installed.
-        });
+            available = available.filter(function (p) {
+                return !platformMap[p]; // Only those not already installed.
+            });
 
-        available = available.map(function (p) {
-            return p.concat(' ', platforms[p].version);
-        });
+            available = available.map(function (p) {
+                return p.concat(' ', platforms[p].version);
+            });
 
-        available = addDeprecatedInformationToPlatforms(available);
-        results += 'Available platforms: \n  ' + available.sort().join('\n  ');
+            available = addDeprecatedInformationToPlatforms(available);
+            results += 'Available platforms: \n  ' + available.sort().join('\n  ');
 
-        events.emit('results', results);
-    }).then(function () {
-        return hooksRunner.fire('after_platform_ls', opts);
-    });
+            events.emit('results', results);
+        }).then(function () {
+            return hooksRunner.fire('after_platform_ls', opts);
+        });
 }
 
 function addDeprecatedInformationToPlatforms (platformsList) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/platform/remove.js
----------------------------------------------------------------------
diff --git a/src/cordova/platform/remove.js b/src/cordova/platform/remove.js
index 1e5bf54..cf7cc41 100644
--- a/src/cordova/platform/remove.js
+++ b/src/cordova/platform/remove.js
@@ -36,63 +36,63 @@ function remove (hooksRunner, projectRoot, targets, opts) {
         return Q.reject(new CordovaError('No platform(s) specified. Please specify platform(s) to remove. See `' + cordova_util.binname + ' platform list`.'));
     }
     return hooksRunner.fire('before_platform_rm', opts)
-    .then(function () {
-        targets.forEach(function (target) {
-            shell.rm('-rf', path.join(projectRoot, 'platforms', target));
-            cordova_util.removePlatformPluginsJson(projectRoot, target);
-        });
-    }).then(function () {
-        var config_json = config.read(projectRoot);
-        var autosave = config_json.auto_save_platforms || false;
-        var modifiedPkgJson = false;
-        var pkgJson;
-        var pkgJsonPath = path.join(projectRoot, 'package.json');
-        // If statement to see if pkgJsonPath exists in the filesystem
-        if (fs.existsSync(pkgJsonPath)) {
-            pkgJson = cordova_util.requireNoCache(pkgJsonPath);
-        }
-        if (opts.save || autosave) {
+        .then(function () {
             targets.forEach(function (target) {
-                var platformName = target.split('@')[0];
-                var xml = cordova_util.projectConfig(projectRoot);
-                var cfg = new ConfigParser(xml);
-                events.emit('log', 'Removing platform ' + target + ' from config.xml file...');
-                cfg.removeEngine(platformName);
-                cfg.write();
-                // If package.json exists and contains a specified platform in cordova.platforms, it will be removed.
-                if (pkgJson !== undefined && pkgJson.cordova !== undefined && pkgJson.cordova.platforms !== undefined) {
-                    var index = pkgJson.cordova.platforms.indexOf(platformName);
-                    // Check if platform exists in platforms array.
-                    if (pkgJson.cordova.platforms !== undefined && index > -1) {
-                        events.emit('log', 'Removing ' + platformName + ' from cordova.platforms array in package.json');
-                        pkgJson.cordova.platforms.splice(index, 1);
-                        modifiedPkgJson = true;
+                shell.rm('-rf', path.join(projectRoot, 'platforms', target));
+                cordova_util.removePlatformPluginsJson(projectRoot, target);
+            });
+        }).then(function () {
+            var config_json = config.read(projectRoot);
+            var autosave = config_json.auto_save_platforms || false;
+            var modifiedPkgJson = false;
+            var pkgJson;
+            var pkgJsonPath = path.join(projectRoot, 'package.json');
+            // If statement to see if pkgJsonPath exists in the filesystem
+            if (fs.existsSync(pkgJsonPath)) {
+                pkgJson = cordova_util.requireNoCache(pkgJsonPath);
+            }
+            if (opts.save || autosave) {
+                targets.forEach(function (target) {
+                    var platformName = target.split('@')[0];
+                    var xml = cordova_util.projectConfig(projectRoot);
+                    var cfg = new ConfigParser(xml);
+                    events.emit('log', 'Removing platform ' + target + ' from config.xml file...');
+                    cfg.removeEngine(platformName);
+                    cfg.write();
+                    // If package.json exists and contains a specified platform in cordova.platforms, it will be removed.
+                    if (pkgJson !== undefined && pkgJson.cordova !== undefined && pkgJson.cordova.platforms !== undefined) {
+                        var index = pkgJson.cordova.platforms.indexOf(platformName);
+                        // Check if platform exists in platforms array.
+                        if (pkgJson.cordova.platforms !== undefined && index > -1) {
+                            events.emit('log', 'Removing ' + platformName + ' from cordova.platforms array in package.json');
+                            pkgJson.cordova.platforms.splice(index, 1);
+                            modifiedPkgJson = true;
+                        }
                     }
+                });
+                // Write out new package.json if changes have been made.
+                if (modifiedPkgJson === true) {
+                    fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
                 }
+            }
+        }).then(function () {
+            // Remove targets from platforms.json.
+            targets.forEach(function (target) {
+                events.emit('verbose', 'Removing platform ' + target + ' from platforms.json file...');
+                platformMetadata.remove(projectRoot, target);
             });
-            // Write out new package.json if changes have been made.
-            if (modifiedPkgJson === true) {
-                fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
+        }).then(function () {
+            // Remove from node_modules if it exists and --fetch was used.
+            if (opts.fetch) {
+                return promiseutil.Q_chainmap(targets, function (target) {
+                    if (target in platforms) {
+                        target = 'cordova-' + target;
+                    }
+                    // Edits package.json.
+                    return npmUninstall(target, projectRoot, opts);
+                });
             }
-        }
-    }).then(function () {
-        // Remove targets from platforms.json.
-        targets.forEach(function (target) {
-            events.emit('verbose', 'Removing platform ' + target + ' from platforms.json file...');
-            platformMetadata.remove(projectRoot, target);
+        }).then(function () {
+            return hooksRunner.fire('after_platform_rm', opts);
         });
-    }).then(function () {
-        // Remove from node_modules if it exists and --fetch was used.
-        if (opts.fetch) {
-            return promiseutil.Q_chainmap(targets, function (target) {
-                if (target in platforms) {
-                    target = 'cordova-' + target;
-                }
-                // Edits package.json.
-                return npmUninstall(target, projectRoot, opts);
-            });
-        }
-    }).then(function () {
-        return hooksRunner.fire('after_platform_rm', opts);
-    });
 }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/platform_metadata.js
----------------------------------------------------------------------
diff --git a/src/cordova/platform_metadata.js b/src/cordova/platform_metadata.js
index bf9682e..4dc101d 100644
--- a/src/cordova/platform_metadata.js
+++ b/src/cordova/platform_metadata.js
@@ -17,47 +17,45 @@
     under the License.
 */
 
+var path = require('path');
+var cordova_util = require('./util');
+var fs = require('fs');
+var Q = require('q');
+var child_process = require('child_process');
 
-var path         = require('path'),
-    cordova_util = require('./util'),
-    fs           = require('fs'),
-    Q            = require('q'),
-    child_process = require('child_process');
-
-
-function getJson(jsonFile) {
+function getJson (jsonFile) {
     return JSON.parse(fs.readFileSync(jsonFile, 'utf-8'));
 }
 
 // Retrieves the platforms and their versions from the platforms.json file
 // Returns an array of {platform: platform, version: version} ...
 // ... where version could be '3.4.0', '/path/to/platform' or 'git://...'
-function getVersions(projectRoot) {
+function getVersions (projectRoot) {
     var platformsDir = path.join(projectRoot, 'platforms');
     var platformsJsonFile = path.join(platformsDir, 'platforms.json');
 
     // If the platforms.json file doesn't exist, retrieve versions from platforms installed on the filesystem...
     // ...Note that in this case, we won't be able to know what source(folder, git-url) the platform came from, we'll just use versions
-    return getPlatVersionsFromFile(platformsJsonFile).fail(function(){
+    return getPlatVersionsFromFile(platformsJsonFile).fail(function () {
         return getPlatVersionsFromFileSystem(projectRoot);
     });
 }
 
 // Returns a promise
-function getPlatVersionsFromFile(platformsJsonFile){
+function getPlatVersionsFromFile (platformsJsonFile) {
 
     var platformData;
 
     // Handle 'file not found' exception and stay within the 'promise monad'
-    try{
+    try {
         platformData = getJson(platformsJsonFile);
-    } catch(e) {
+    } catch (e) {
         return Q.reject(e);
     }
 
     var platformVersions = [];
 
-    platformVersions = Object.keys(platformData).map(function(p){
+    platformVersions = Object.keys(platformData).map(function (p) {
         return {platform: p, version: platformData[p]};
     });
 
@@ -65,11 +63,11 @@ function getPlatVersionsFromFile(platformsJsonFile){
 }
 
 // Returns a promise
-function getPlatVersionsFromFileSystem(projectRoot){
+function getPlatVersionsFromFileSystem (projectRoot) {
     var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
-    var platformVersions = platforms_on_fs.map(function(platform){
+    var platformVersions = platforms_on_fs.map(function (platform) {
         var script = path.join(projectRoot, 'platforms', platform, 'cordova', 'version');
-        return Q.ninvoke(child_process, 'exec', script, {}).then(function(result){
+        return Q.ninvoke(child_process, 'exec', script, {}).then(function (result) {
             var version = result[0];
 
             // clean the version we get back from the script
@@ -85,22 +83,22 @@ function getPlatVersionsFromFileSystem(projectRoot){
 }
 
 // Saves platform@version into platforms.json
-function save(projectRoot, platform, version) {
+function save (projectRoot, platform, version) {
     var platformsDir = path.join(projectRoot, 'platforms');
     var platformJsonFile = path.join(platformsDir, 'platforms.json');
 
     var data = {};
-    if(fs.existsSync(platformJsonFile)){
+    if (fs.existsSync(platformJsonFile)) {
         data = getJson(platformJsonFile);
     }
     data[platform] = version;
     fs.writeFileSync(platformJsonFile, JSON.stringify(data, null, 2), 'utf-8');
 }
 
-function remove(projectRoot, platform){
+function remove (projectRoot, platform) {
     var platformsDir = path.join(projectRoot, 'platforms');
     var platformJsonFile = path.join(platformsDir, 'platforms.json');
-    if(!fs.existsSync(platformJsonFile)){
+    if (!fs.existsSync(platformJsonFile)) {
         return;
     }
     var data = getJson(platformJsonFile);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/plugin/add.js
----------------------------------------------------------------------
diff --git a/src/cordova/plugin/add.js b/src/cordova/plugin/add.js
index 4e975d3..203cf09 100644
--- a/src/cordova/plugin/add.js
+++ b/src/cordova/plugin/add.js
@@ -70,157 +70,156 @@ function add (projectRoot, hooksRunner, opts) {
 
     opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
     return hooksRunner.fire('before_plugin_add', opts)
-    .then(function () {
-        var pluginInfoProvider = new PluginInfoProvider();
-        return opts.plugins.reduce(function (soFar, target) {
-            return soFar.then(function () {
-                if (target[target.length - 1] === path.sep) {
-                    target = target.substring(0, target.length - 1);
-                }
-
-                // Fetch the plugin first.
-                var fetchOptions = {
-                    searchpath: searchPath,
-                    noregistry: opts.noregistry,
-                    fetch: opts.fetch || false,
-                    save: opts.save,
-                    nohooks: opts.nohooks,
-                    link: opts.link,
-                    pluginInfoProvider: pluginInfoProvider,
-                    variables: opts.cli_variables,
-                    is_top_level: true
-                };
-
-                return module.exports.determinePluginTarget(projectRoot, cfg, target, fetchOptions).then(function (resolvedTarget) {
-                    target = resolvedTarget;
-                    events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
-                    return plugman.fetch(target, pluginPath, fetchOptions);
-                });
-            }).then(function (directory) {
-                return pluginInfoProvider.get(directory);
-            }).then(function (pluginInfo) {
-                // Validate top-level required variables
-                var pluginVariables = pluginInfo.getPreferences();
-                opts.cli_variables = opts.cli_variables || {};
-                var pluginEntry = cfg.getPlugin(pluginInfo.id);
-                // Get variables from config.xml
-                var configVariables = pluginEntry ? pluginEntry.variables : {};
-                // Add config variable if it's missing in cli_variables
-                Object.keys(configVariables).forEach(function (variable) {
-                    opts.cli_variables[variable] = opts.cli_variables[variable] || configVariables[variable];
-                });
-                var missingVariables = Object.keys(pluginVariables)
-                .filter(function (variableName) {
-                    // discard variables with default value
-                    return !(pluginVariables[variableName] || opts.cli_variables[variableName]);
-                });
-
-                if (missingVariables.length) {
-                    events.emit('verbose', 'Removing ' + pluginInfo.dir + ' because mandatory plugin variables were missing.');
-                    shell.rm('-rf', pluginInfo.dir);
-                    var msg = 'Variable(s) missing (use: --variable ' + missingVariables.join('=value --variable ') + '=value).';
-                    return Q.reject(new CordovaError(msg));
-                }
+        .then(function () {
+            var pluginInfoProvider = new PluginInfoProvider();
+            return opts.plugins.reduce(function (soFar, target) {
+                return soFar.then(function () {
+                    if (target[target.length - 1] === path.sep) {
+                        target = target.substring(0, target.length - 1);
+                    }
 
-                // Iterate (in serial!) over all platforms in the project and install the plugin.
-                return chainMap(platformList, function (platform) {
-                    var platformRoot = path.join(projectRoot, 'platforms', platform);
-                    var options = {
-                        cli_variables: opts.cli_variables || {},
-                        browserify: opts.browserify || false,
-                        fetch: opts.fetch || false,
-                        save: opts.save,
+                    // Fetch the plugin first.
+                    var fetchOptions = {
                         searchpath: searchPath,
                         noregistry: opts.noregistry,
+                        fetch: opts.fetch || false,
+                        save: opts.save,
+                        nohooks: opts.nohooks,
                         link: opts.link,
                         pluginInfoProvider: pluginInfoProvider,
-                        // Set up platform to install asset files/js modules to <platform>/platform_www dir
-                        // instead of <platform>/www. This is required since on each prepare platform's www dir is changed
-                        // and files from 'platform_www' merged into 'www'. Thus we need to persist these
-                        // files platform_www directory, so they'll be applied to www on each prepare.
-                        usePlatformWww: true,
-                        nohooks: opts.nohooks,
-                        force: opts.force
+                        variables: opts.cli_variables,
+                        is_top_level: true
                     };
 
-                    events.emit('verbose', 'Calling plugman.install on plugin "' + pluginInfo.dir + '" for platform "' + platform);
-                    return plugman.install(platform, platformRoot, path.basename(pluginInfo.dir), pluginPath, options)
-                    .then(function (didPrepare) {
-                        // If platform does not returned anything we'll need
-                        // to trigger a prepare after all plugins installed
-                        if (!didPrepare) shouldRunPrepare = true;
+                    return module.exports.determinePluginTarget(projectRoot, cfg, target, fetchOptions).then(function (resolvedTarget) {
+                        target = resolvedTarget;
+                        events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
+                        return plugman.fetch(target, pluginPath, fetchOptions);
                     });
-                })
-                .thenResolve(pluginInfo);
-            })
-            .then(function (pluginInfo) {
-                var pkgJson;
-                var pkgJsonPath = path.join(projectRoot, 'package.json');
-
-                // save to config.xml
-                if (plugin_util.saveToConfigXmlOn(config_json, opts)) {
-                    // If statement to see if pkgJsonPath exists in the filesystem
-                    if (fs.existsSync(pkgJsonPath)) {
-                        // Delete any previous caches of require(package.json)
-                        pkgJson = cordova_util.requireNoCache(pkgJsonPath);
-                    }
-                    // If package.json exists, the plugin object and plugin name
-                    // will be added to package.json if not already there.
-                    if (pkgJson) {
-                        pkgJson.cordova = pkgJson.cordova || {};
-                        pkgJson.cordova.plugins = pkgJson.cordova.plugins || {};
-                        // Plugin and variables are added.
-                        pkgJson.cordova.plugins[pluginInfo.id] = opts.cli_variables;
-                        events.emit('log', 'Adding ' + pluginInfo.id + ' to package.json');
-
-                        // Write to package.json
-                        fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
+                }).then(function (directory) {
+                    return pluginInfoProvider.get(directory);
+                }).then(function (pluginInfo) {
+                    // Validate top-level required variables
+                    var pluginVariables = pluginInfo.getPreferences();
+                    opts.cli_variables = opts.cli_variables || {};
+                    var pluginEntry = cfg.getPlugin(pluginInfo.id);
+                    // Get variables from config.xml
+                    var configVariables = pluginEntry ? pluginEntry.variables : {};
+                    // Add config variable if it's missing in cli_variables
+                    Object.keys(configVariables).forEach(function (variable) {
+                        opts.cli_variables[variable] = opts.cli_variables[variable] || configVariables[variable];
+                    });
+                    var missingVariables = Object.keys(pluginVariables)
+                        .filter(function (variableName) {
+                            // discard variables with default value
+                            return !(pluginVariables[variableName] || opts.cli_variables[variableName]);
+                        });
+
+                    if (missingVariables.length) {
+                        events.emit('verbose', 'Removing ' + pluginInfo.dir + ' because mandatory plugin variables were missing.');
+                        shell.rm('-rf', pluginInfo.dir);
+                        var msg = 'Variable(s) missing (use: --variable ' + missingVariables.join('=value --variable ') + '=value).';
+                        return Q.reject(new CordovaError(msg));
                     }
 
-                    var src = module.exports.parseSource(target, opts);
-                    var attributes = {
-                        name: pluginInfo.id
-                    };
+                    // Iterate (in serial!) over all platforms in the project and install the plugin.
+                    return chainMap(platformList, function (platform) {
+                        var platformRoot = path.join(projectRoot, 'platforms', platform);
+                        var options = {
+                            cli_variables: opts.cli_variables || {},
+                            browserify: opts.browserify || false,
+                            fetch: opts.fetch || false,
+                            save: opts.save,
+                            searchpath: searchPath,
+                            noregistry: opts.noregistry,
+                            link: opts.link,
+                            pluginInfoProvider: pluginInfoProvider,
+                            // Set up platform to install asset files/js modules to <platform>/platform_www dir
+                            // instead of <platform>/www. This is required since on each prepare platform's www dir is changed
+                            // and files from 'platform_www' merged into 'www'. Thus we need to persist these
+                            // files platform_www directory, so they'll be applied to www on each prepare.
+                            usePlatformWww: true,
+                            nohooks: opts.nohooks,
+                            force: opts.force
+                        };
+
+                        events.emit('verbose', 'Calling plugman.install on plugin "' + pluginInfo.dir + '" for platform "' + platform);
+                        return plugman.install(platform, platformRoot, path.basename(pluginInfo.dir), pluginPath, options)
+                            .then(function (didPrepare) {
+                                // If platform does not returned anything we'll need
+                                // to trigger a prepare after all plugins installed
+                                if (!didPrepare) shouldRunPrepare = true;
+                            });
+                    })
+                        .thenResolve(pluginInfo);
+                }).then(function (pluginInfo) {
+                    var pkgJson;
+                    var pkgJsonPath = path.join(projectRoot, 'package.json');
+
+                    // save to config.xml
+                    if (plugin_util.saveToConfigXmlOn(config_json, opts)) {
+                        // If statement to see if pkgJsonPath exists in the filesystem
+                        if (fs.existsSync(pkgJsonPath)) {
+                            // Delete any previous caches of require(package.json)
+                            pkgJson = cordova_util.requireNoCache(pkgJsonPath);
+                        }
+                        // If package.json exists, the plugin object and plugin name
+                        // will be added to package.json if not already there.
+                        if (pkgJson) {
+                            pkgJson.cordova = pkgJson.cordova || {};
+                            pkgJson.cordova.plugins = pkgJson.cordova.plugins || {};
+                            // Plugin and variables are added.
+                            pkgJson.cordova.plugins[pluginInfo.id] = opts.cli_variables;
+                            events.emit('log', 'Adding ' + pluginInfo.id + ' to package.json');
+
+                            // Write to package.json
+                            fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
+                        }
 
-                    if (src) {
-                        attributes.spec = src;
-                    } else {
-                        var ver = '~' + pluginInfo.version;
-                        // Scoped packages need to have the package-spec along with the version
-                        var parsedSpec = pluginSpec.parse(target);
-                        if (pkgJson && pkgJson.dependencies && pkgJson.dependencies[pluginInfo.id]) {
-                            attributes.spec = pkgJson.dependencies[pluginInfo.id];
+                        var src = module.exports.parseSource(target, opts);
+                        var attributes = {
+                            name: pluginInfo.id
+                        };
+
+                        if (src) {
+                            attributes.spec = src;
                         } else {
-                            if (parsedSpec.scope) {
-                                attributes.spec = parsedSpec.package + '@' + ver;
+                            var ver = '~' + pluginInfo.version;
+                            // Scoped packages need to have the package-spec along with the version
+                            var parsedSpec = pluginSpec.parse(target);
+                            if (pkgJson && pkgJson.dependencies && pkgJson.dependencies[pluginInfo.id]) {
+                                attributes.spec = pkgJson.dependencies[pluginInfo.id];
                             } else {
-                                attributes.spec = ver;
+                                if (parsedSpec.scope) {
+                                    attributes.spec = parsedSpec.package + '@' + ver;
+                                } else {
+                                    attributes.spec = ver;
+                                }
                             }
                         }
-                    }
-                    xml = cordova_util.projectConfig(projectRoot);
-                    cfg = new ConfigParser(xml);
-                    cfg.removePlugin(pluginInfo.id);
-                    cfg.addPlugin(attributes, opts.cli_variables);
-                    cfg.write();
+                        xml = cordova_util.projectConfig(projectRoot);
+                        cfg = new ConfigParser(xml);
+                        cfg.removePlugin(pluginInfo.id);
+                        cfg.addPlugin(attributes, opts.cli_variables);
+                        cfg.write();
 
-                    events.emit('results', 'Saved plugin info for "' + pluginInfo.id + '" to config.xml');
-                }
-            });
-        }, Q());
-    }).then(function () {
-        // CB-11022 We do not need to run prepare after plugin install until shouldRunPrepare flag is set to true
-        if (!shouldRunPrepare) {
-            return Q();
-        }
-        // Need to require right here instead of doing this at the beginning of file
-        // otherwise tests are failing without any real reason.
-        // TODO: possible circular dependency?
-        return require('../prepare').preparePlatforms(platformList, projectRoot, opts);
-    }).then(function () {
-        opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
-        return hooksRunner.fire('after_plugin_add', opts);
-    });
+                        events.emit('results', 'Saved plugin info for "' + pluginInfo.id + '" to config.xml');
+                    }
+                });
+            }, Q());
+        }).then(function () {
+            // CB-11022 We do not need to run prepare after plugin install until shouldRunPrepare flag is set to true
+            if (!shouldRunPrepare) {
+                return Q();
+            }
+            // Need to require right here instead of doing this at the beginning of file
+            // otherwise tests are failing without any real reason.
+            // TODO: possible circular dependency?
+            return require('../prepare').preparePlatforms(platformList, projectRoot, opts);
+        }).then(function () {
+            opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
+            return hooksRunner.fire('after_plugin_add', opts);
+        });
 }
 
 function determinePluginTarget (projectRoot, cfg, target, fetchOptions) {
@@ -299,12 +298,12 @@ function determinePluginTarget (projectRoot, cfg, target, fetchOptions) {
 
     // TODO: whoa wat
     return (shouldUseNpmInfo ? registry.info([id])
-    .then(function (pluginInfo) {
-        return module.exports.getFetchVersion(projectRoot, pluginInfo, cordovaVersion);
-    }) : Q(null))
-    .then(function (fetchVersion) {
-        return fetchVersion ? (id + '@' + fetchVersion) : target;
-    });
+        .then(function (pluginInfo) {
+            return module.exports.getFetchVersion(projectRoot, pluginInfo, cordovaVersion);
+        }) : Q(null))
+        .then(function (fetchVersion) {
+            return fetchVersion ? (id + '@' + fetchVersion) : target;
+        });
 }
 
 function parseSource (target, opts) {
@@ -359,13 +358,13 @@ function getFetchVersion (projectRoot, pluginInfo, cordovaVersion) {
         });
 
         return cordova_util.getInstalledPlatformsWithVersions(projectRoot)
-        .then(function (platformVersions) {
-            return module.exports.determinePluginVersionToFetch(
-                pluginInfo,
-                pluginMap,
-                platformVersions,
-                cordovaVersion);
-        });
+            .then(function (platformVersions) {
+                return module.exports.determinePluginVersionToFetch(
+                    pluginInfo,
+                    pluginMap,
+                    platformVersions,
+                    cordovaVersion);
+            });
     } else {
         // If we have no engine, we want to fall back to the default behavior
         events.emit('verbose', 'npm info for ' + pluginInfo.name + ' did not contain any engine info. Fetching latest release');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/plugin/list.js
----------------------------------------------------------------------
diff --git a/src/cordova/plugin/list.js b/src/cordova/plugin/list.js
index 78d9521..ab634e0 100644
--- a/src/cordova/plugin/list.js
+++ b/src/cordova/plugin/list.js
@@ -27,49 +27,49 @@ module.exports = list;
 function list (projectRoot, hooksRunner, opts) {
     var pluginsList = [];
     return hooksRunner.fire('before_plugin_ls', opts)
-    .then(function () {
-        return plugin_util.getInstalledPlugins(projectRoot);
-    }).then(function (plugins) {
-        if (plugins.length === 0) {
-            events.emit('results', 'No plugins added. Use `' + cordova_util.binname + ' plugin add <plugin>`.');
-            return;
-        }
-        var pluginsDict = {};
-        var lines = [];
-        var txt, p;
-        for (var i = 0; i < plugins.length; i++) {
-            p = plugins[i];
-            pluginsDict[p.id] = p;
-            pluginsList.push(p.id);
-            txt = p.id + ' ' + p.version + ' "' + (p.name || p.description) + '"';
-            lines.push(txt);
-        }
-        // Add warnings for deps with wrong versions.
-        for (var id in pluginsDict) {
-            p = pluginsDict[id];
-            for (var depId in p.deps) {
-                var dep = pluginsDict[depId];
-                // events.emit('results', p.deps[depId].version);
-                // events.emit('results', dep != null);
-                if (!dep) {
-                    txt = 'WARNING, missing dependency: plugin ' + id +
-                          ' depends on ' + depId +
-                          ' but it is not installed';
-                    lines.push(txt);
-                } else if (!semver.satisfies(dep.version, p.deps[depId].version)) {
-                    txt = 'WARNING, broken dependency: plugin ' + id +
-                          ' depends on ' + depId + ' ' + p.deps[depId].version +
-                          ' but installed version is ' + dep.version;
-                    lines.push(txt);
+        .then(function () {
+            return plugin_util.getInstalledPlugins(projectRoot);
+        }).then(function (plugins) {
+            if (plugins.length === 0) {
+                events.emit('results', 'No plugins added. Use `' + cordova_util.binname + ' plugin add <plugin>`.');
+                return;
+            }
+            var pluginsDict = {};
+            var lines = [];
+            var txt, p;
+            for (var i = 0; i < plugins.length; i++) {
+                p = plugins[i];
+                pluginsDict[p.id] = p;
+                pluginsList.push(p.id);
+                txt = p.id + ' ' + p.version + ' "' + (p.name || p.description) + '"';
+                lines.push(txt);
+            }
+            // Add warnings for deps with wrong versions.
+            for (var id in pluginsDict) {
+                p = pluginsDict[id];
+                for (var depId in p.deps) {
+                    var dep = pluginsDict[depId];
+                    // events.emit('results', p.deps[depId].version);
+                    // events.emit('results', dep != null);
+                    if (!dep) {
+                        txt = 'WARNING, missing dependency: plugin ' + id +
+                              ' depends on ' + depId +
+                              ' but it is not installed';
+                        lines.push(txt);
+                    } else if (!semver.satisfies(dep.version, p.deps[depId].version)) {
+                        txt = 'WARNING, broken dependency: plugin ' + id +
+                              ' depends on ' + depId + ' ' + p.deps[depId].version +
+                              ' but installed version is ' + dep.version;
+                        lines.push(txt);
+                    }
                 }
             }
-        }
-        events.emit('results', lines.join('\n'));
-    })
-    .then(function () {
-        return hooksRunner.fire('after_plugin_ls', opts);
-    })
-    .then(function () {
-        return pluginsList;
-    });
+            events.emit('results', lines.join('\n'));
+        })
+        .then(function () {
+            return hooksRunner.fire('after_plugin_ls', opts);
+        })
+        .then(function () {
+            return pluginsList;
+        });
 }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/plugin/plugin_spec_parser.js
----------------------------------------------------------------------
diff --git a/src/cordova/plugin/plugin_spec_parser.js b/src/cordova/plugin/plugin_spec_parser.js
index 7ad1bae..3d41248 100644
--- a/src/cordova/plugin/plugin_spec_parser.js
+++ b/src/cordova/plugin/plugin_spec_parser.js
@@ -18,7 +18,7 @@
 */
 
 // npm packages follow the pattern of (@scope/)?package(@spec)? where scope and tag are optional
-var NPM_SPEC_REGEX = /^(@[^\/]+\/)?([^@\/]+)(?:@(.+))?$/;
+var NPM_SPEC_REGEX = /^(@[^\/]+\/)?([^@\/]+)(?:@(.+))?$/; // eslint-disable-line no-useless-escape
 
 module.exports.parse = parse;
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/plugin/remove.js
----------------------------------------------------------------------
diff --git a/src/cordova/plugin/remove.js b/src/cordova/plugin/remove.js
index 01de6fb..6cbd930 100644
--- a/src/cordova/plugin/remove.js
+++ b/src/cordova/plugin/remove.js
@@ -44,79 +44,79 @@ function remove (projectRoot, targets, hooksRunner, opts) {
 
     opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
     return hooksRunner.fire('before_plugin_rm', opts)
-    .then(function () {
-        return opts.plugins.reduce(function (soFar, target) {
-            var validatedPluginId = module.exports.validatePluginId(target, plugins);
-            if (!validatedPluginId) {
-                return Q.reject(new CordovaError('Plugin "' + target + '" is not present in the project. See `' + cordova_util.binname + ' plugin list`.'));
-            }
-            target = validatedPluginId;
+        .then(function () {
+            return opts.plugins.reduce(function (soFar, target) {
+                var validatedPluginId = module.exports.validatePluginId(target, plugins);
+                if (!validatedPluginId) {
+                    return Q.reject(new CordovaError('Plugin "' + target + '" is not present in the project. See `' + cordova_util.binname + ' plugin list`.'));
+                }
+                target = validatedPluginId;
 
-            // Iterate over all installed platforms and uninstall.
-            // If this is a web-only or dependency-only plugin, then
-            // there may be nothing to do here except remove the
-            // reference from the platform's plugin config JSON.
-            return platformList.reduce(function (soFar, platform) {
-                return soFar.then(function () {
-                    var platformRoot = path.join(projectRoot, 'platforms', platform);
-                    events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
-                    var options = {
-                        force: opts.force || false
-                    };
-                    return plugman.uninstall.uninstallPlatform(platform, platformRoot, target, pluginPath, options)
-                    .then(function (didPrepare) {
-                        // If platform does not returned anything we'll need
-                        // to trigger a prepare after all plugins installed
-                        // TODO: if didPrepare is falsy, what does that imply? WHY are we doing this?
-                        if (!didPrepare) shouldRunPrepare = true;
+                // Iterate over all installed platforms and uninstall.
+                // If this is a web-only or dependency-only plugin, then
+                // there may be nothing to do here except remove the
+                // reference from the platform's plugin config JSON.
+                return platformList.reduce(function (soFar, platform) {
+                    return soFar.then(function () {
+                        var platformRoot = path.join(projectRoot, 'platforms', platform);
+                        events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
+                        var options = {
+                            force: opts.force || false
+                        };
+                        return plugman.uninstall.uninstallPlatform(platform, platformRoot, target, pluginPath, options)
+                            .then(function (didPrepare) {
+                                // If platform does not returned anything we'll need
+                                // to trigger a prepare after all plugins installed
+                                // TODO: if didPrepare is falsy, what does that imply? WHY are we doing this?
+                                if (!didPrepare) shouldRunPrepare = true;
+                            });
                     });
-                });
-            }, Q())
-            .then(function () {
-                // TODO: Should only uninstallPlugin when no platforms have it.
-                return plugman.uninstall.uninstallPlugin(target, pluginPath, opts);
-            }).then(function () {
-                // remove plugin from config.xml
-                if (plugin_util.saveToConfigXmlOn(config_json, opts)) {
-                    events.emit('log', 'Removing plugin ' + target + ' from config.xml file...');
-                    var configPath = cordova_util.projectConfig(projectRoot);
-                    if (fs.existsSync(configPath)) { // should not happen with real life but needed for tests
-                        var configXml = new ConfigParser(configPath);
-                        configXml.removePlugin(target);
-                        configXml.write();
-                    }
-                    var pkgJson;
-                    var pkgJsonPath = path.join(projectRoot, 'package.json');
-                    // If statement to see if pkgJsonPath exists in the filesystem
-                    if (fs.existsSync(pkgJsonPath)) {
-                        // delete any previous caches of require(package.json)
-                        pkgJson = cordova_util.requireNoCache(pkgJsonPath);
-                    }
-                    // If package.json exists and contains a specified plugin in cordova['plugins'], it will be removed
-                    if (pkgJson !== undefined && pkgJson.cordova !== undefined && pkgJson.cordova.plugins !== undefined) {
-                        events.emit('log', 'Removing ' + target + ' from package.json');
-                        // Remove plugin from package.json
-                        delete pkgJson.cordova.plugins[target];
-                        // Write out new package.json with plugin removed correctly.
-                        fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
-                    }
-                }
-            }).then(function () {
-                // Remove plugin from fetch.json
-                events.emit('verbose', 'Removing plugin ' + target + ' from fetch.json');
-                metadata.remove_fetch_metadata(pluginPath, target);
-            });
-        }, Q());
-    }).then(function () {
-        // CB-11022 We do not need to run prepare after plugin install until shouldRunPrepare flag is set to true
-        if (!shouldRunPrepare) {
-            return Q();
-        }
-        return require('../prepare').preparePlatforms(platformList, projectRoot, opts);
-    }).then(function () {
-        opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
-        return hooksRunner.fire('after_plugin_rm', opts);
-    });
+                }, Q())
+                    .then(function () {
+                        // TODO: Should only uninstallPlugin when no platforms have it.
+                        return plugman.uninstall.uninstallPlugin(target, pluginPath, opts);
+                    }).then(function () {
+                        // remove plugin from config.xml
+                        if (plugin_util.saveToConfigXmlOn(config_json, opts)) {
+                            events.emit('log', 'Removing plugin ' + target + ' from config.xml file...');
+                            var configPath = cordova_util.projectConfig(projectRoot);
+                            if (fs.existsSync(configPath)) { // should not happen with real life but needed for tests
+                                var configXml = new ConfigParser(configPath);
+                                configXml.removePlugin(target);
+                                configXml.write();
+                            }
+                            var pkgJson;
+                            var pkgJsonPath = path.join(projectRoot, 'package.json');
+                            // If statement to see if pkgJsonPath exists in the filesystem
+                            if (fs.existsSync(pkgJsonPath)) {
+                                // delete any previous caches of require(package.json)
+                                pkgJson = cordova_util.requireNoCache(pkgJsonPath);
+                            }
+                            // If package.json exists and contains a specified plugin in cordova['plugins'], it will be removed
+                            if (pkgJson !== undefined && pkgJson.cordova !== undefined && pkgJson.cordova.plugins !== undefined) {
+                                events.emit('log', 'Removing ' + target + ' from package.json');
+                                // Remove plugin from package.json
+                                delete pkgJson.cordova.plugins[target];
+                                // Write out new package.json with plugin removed correctly.
+                                fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), 'utf8');
+                            }
+                        }
+                    }).then(function () {
+                        // Remove plugin from fetch.json
+                        events.emit('verbose', 'Removing plugin ' + target + ' from fetch.json');
+                        metadata.remove_fetch_metadata(pluginPath, target);
+                    });
+            }, Q());
+        }).then(function () {
+            // CB-11022 We do not need to run prepare after plugin install until shouldRunPrepare flag is set to true
+            if (!shouldRunPrepare) {
+                return Q();
+            }
+            return require('../prepare').preparePlatforms(platformList, projectRoot, opts);
+        }).then(function () {
+            opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
+            return hooksRunner.fire('after_plugin_rm', opts);
+        });
 }
 
 function validatePluginId (pluginId, installedPlugins) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/plugin/search.js
----------------------------------------------------------------------
diff --git a/src/cordova/plugin/search.js b/src/cordova/plugin/search.js
index 0108e4e..a419db8 100644
--- a/src/cordova/plugin/search.js
+++ b/src/cordova/plugin/search.js
@@ -24,18 +24,18 @@ module.exports = search;
 
 function search (hooksRunner, opts) {
     return hooksRunner.fire('before_plugin_search', opts)
-    .then(function () {
-        var link = 'http://cordova.apache.org/plugins/';
-        if (opts.plugins.length > 0) {
-            var keywords = (opts.plugins).join(' ');
-            var query = link + '?q=' + encodeURI(keywords);
-            opener(query);
-        } else {
-            opener(link);
-        }
+        .then(function () {
+            var link = 'http://cordova.apache.org/plugins/';
+            if (opts.plugins.length > 0) {
+                var keywords = (opts.plugins).join(' ');
+                var query = link + '?q=' + encodeURI(keywords);
+                opener(query);
+            } else {
+                opener(link);
+            }
 
-        return Q.resolve();
-    }).then(function () {
-        return hooksRunner.fire('after_plugin_search', opts);
-    });
+            return Q.resolve();
+        }).then(function () {
+            return hooksRunner.fire('after_plugin_search', opts);
+        });
 }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/prepare.js
----------------------------------------------------------------------
diff --git a/src/cordova/prepare.js b/src/cordova/prepare.js
index 9c02d51..7353a03 100644
--- a/src/cordova/prepare.js
+++ b/src/cordova/prepare.js
@@ -44,30 +44,30 @@ function prepare (options) {
         options.fetch = options.fetch || false;
         var hooksRunner = new HooksRunner(projectRoot);
         return hooksRunner.fire('before_prepare', options)
-        .then(function () {
-            return restore.installPlatformsFromConfigXML(options.platforms, { searchpath: options.searchpath, fetch: options.fetch, restoring: true });
-        })
-        .then(function () {
-            options = cordova_util.preProcessOptions(options);
-            var paths = options.platforms.map(function (p) {
-                var platform_path = path.join(projectRoot, 'platforms', p);
-                return platforms.getPlatformApi(p, platform_path).getPlatformInfo().locations.www;
-            });
-            options.paths = paths;
-        }).then(function () {
-            options = cordova_util.preProcessOptions(options);
-            return restore.installPluginsFromConfigXML(options);
-        }).then(function () {
-            options = cordova_util.preProcessOptions(options);
-            options.searchpath = options.searchpath || config_json.plugin_search_path;
-            // Iterate over each added platform
-            return module.exports.preparePlatforms(options.platforms, projectRoot, options);
-        }).then(function () {
-            options.paths = options.platforms.map(function (platform) {
-                return platforms.getPlatformApi(platform).getPlatformInfo().locations.www;
+            .then(function () {
+                return restore.installPlatformsFromConfigXML(options.platforms, { searchpath: options.searchpath, fetch: options.fetch, restoring: true });
+            })
+            .then(function () {
+                options = cordova_util.preProcessOptions(options);
+                var paths = options.platforms.map(function (p) {
+                    var platform_path = path.join(projectRoot, 'platforms', p);
+                    return platforms.getPlatformApi(p, platform_path).getPlatformInfo().locations.www;
+                });
+                options.paths = paths;
+            }).then(function () {
+                options = cordova_util.preProcessOptions(options);
+                return restore.installPluginsFromConfigXML(options);
+            }).then(function () {
+                options = cordova_util.preProcessOptions(options);
+                options.searchpath = options.searchpath || config_json.plugin_search_path;
+                // Iterate over each added platform
+                return module.exports.preparePlatforms(options.platforms, projectRoot, options);
+            }).then(function () {
+                options.paths = options.platforms.map(function (platform) {
+                    return platforms.getPlatformApi(platform).getPlatformInfo().locations.www;
+                });
+                return hooksRunner.fire('after_prepare', options);
             });
-            return hooksRunner.fire('after_prepare', options);
-        });
     });
 }
 
@@ -93,43 +93,43 @@ function preparePlatforms (platformList, projectRoot, options) {
         };
         // CB-9987 We need to reinstall the plugins for the platform it they were added by cordova@<5.4.0
         return module.exports.restoreMissingPluginsForPlatform(platform, projectRoot, options)
-        .then(function () {
-            // platformApi prepare takes care of all functionality
-            // which previously had been executed by cordova.prepare:
-            //   - reset config.xml and then merge changes from project's one,
-            //   - update www directory from project's one and merge assets from platform_www,
-            //   - reapply config changes, made by plugins,
-            //   - update platform's project
-            // Please note that plugins' changes, such as installed js files, assets and
-            // config changes is not being reinstalled on each prepare.
-            var platformApi = platforms.getPlatformApi(platform);
-            return platformApi.prepare(project, _.clone(options))
             .then(function () {
-                if (platform === 'windows') {
-                    // Windows Api doesn't fire 'pre_package' hook, so we fire it here
-                    return new HooksRunner(projectRoot).fire('pre_package', {
-                        wwwPath: platformApi.getPlatformInfo().locations.www,
-                        platforms: ['windows'],
-                        nohooks: options.nohooks
+                // platformApi prepare takes care of all functionality
+                // which previously had been executed by cordova.prepare:
+                //   - reset config.xml and then merge changes from project's one,
+                //   - update www directory from project's one and merge assets from platform_www,
+                //   - reapply config changes, made by plugins,
+                //   - update platform's project
+                // Please note that plugins' changes, such as installed js files, assets and
+                // config changes is not being reinstalled on each prepare.
+                var platformApi = platforms.getPlatformApi(platform);
+                return platformApi.prepare(project, _.clone(options))
+                    .then(function () {
+                        if (platform === 'windows') {
+                            // Windows Api doesn't fire 'pre_package' hook, so we fire it here
+                            return new HooksRunner(projectRoot).fire('pre_package', {
+                                wwwPath: platformApi.getPlatformInfo().locations.www,
+                                platforms: ['windows'],
+                                nohooks: options.nohooks
+                            });
+                        }
+                    })
+                    .then(function () {
+                        if (options.browserify) {
+                            // TODO: dynamic require here makes it difficult to test this code branch.
+                            var browserify = require('../plugman/browserify');
+                            return browserify(project, platformApi);
+                        }
+                    })
+                    .then(function () {
+                        // Handle edit-config in config.xml
+                        var platformRoot = path.join(projectRoot, 'platforms', platform);
+                        var platformJson = PlatformJson.load(platformRoot, platform);
+                        var munger = new PlatformMunger(platform, platformRoot, platformJson);
+                        // the boolean argument below is "should_increment"
+                        munger.add_config_changes(project.projectConfig, true).save_all();
                     });
-                }
-            })
-            .then(function () {
-                if (options.browserify) {
-                    // TODO: dynamic require here makes it difficult to test this code branch.
-                    var browserify = require('../plugman/browserify');
-                    return browserify(project, platformApi);
-                }
-            })
-            .then(function () {
-                // Handle edit-config in config.xml
-                var platformRoot = path.join(projectRoot, 'platforms', platform);
-                var platformJson = PlatformJson.load(platformRoot, platform);
-                var munger = new PlatformMunger(platform, platformRoot, platformJson);
-                // the boolean argument below is "should_increment"
-                munger.add_config_changes(project.projectConfig, true).save_all();
             });
-        });
     }));
 }
 
@@ -184,9 +184,9 @@ function restoreMissingPluginsForPlatform (platform, projectRoot, options) {
             events.emit('verbose', 'Reinstalling missing plugin ' + plugin.name + ' in ' + platform + ' platform');
             var pluginInfo = provider.get(path.join(projectRoot, 'plugins', plugin.name));
             return api.removePlugin(pluginInfo, pluginOptions)
-            .then(function () {
-                return api.addPlugin(pluginInfo, pluginOptions);
-            });
+                .then(function () {
+                    return api.addPlugin(pluginInfo, pluginOptions);
+                });
         });
     }, Q());
 }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/project_metadata.js
----------------------------------------------------------------------
diff --git a/src/cordova/project_metadata.js b/src/cordova/project_metadata.js
index afde4e0..1eb1cca 100644
--- a/src/cordova/project_metadata.js
+++ b/src/cordova/project_metadata.js
@@ -17,17 +17,16 @@
     under the License.
 */
 
-var cordova_util = require('./util'),
-    ConfigParser = require('cordova-common').ConfigParser,
-    Q            = require('q'),
-    semver       = require('semver');
-
+var cordova_util = require('./util');
+var ConfigParser = require('cordova-common').ConfigParser;
+var Q = require('q');
+var semver = require('semver');
 
 /** Returns all the platforms that are currently saved into config.xml
  *  @return {Promise<{name: string, version: string, src: string}[]>}
  *      e.g: [ {name: 'android', version: '3.5.0'}, {name: 'wp8', src: 'C:/path/to/platform'}, {name: 'ios', src: 'git://...'} ]
  */
-function getPlatforms(projectRoot){
+function getPlatforms (projectRoot) {
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new ConfigParser(xml);
 
@@ -53,7 +52,7 @@ function getPlatforms(projectRoot){
  *  @return {Promise<{id: string, version: string, variables: {name: string, value: string}[]}[]>}
  *      e.g: [ {id: 'org.apache.cordova.device', variables: [{name: 'APP_ID', value: 'my-app-id'}, {name: 'APP_NAME', value: 'my-app-name'}]} ]
  */
-function getPlugins(projectRoot){
+function getPlugins (projectRoot) {
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new ConfigParser(xml);
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/remote_load.js
----------------------------------------------------------------------
diff --git a/src/cordova/remote_load.js b/src/cordova/remote_load.js
index 90aa0b1..c6b72d6 100644
--- a/src/cordova/remote_load.js
+++ b/src/cordova/remote_load.js
@@ -31,7 +31,7 @@ passed containing a packageName, name, and version.
 
 options - Package options
  */
-function npmFetch(packageName, packageVersion) {
+function npmFetch (packageName, packageVersion) {
     return npmHelper.fetchPackage(packageName, packageVersion);
 }
 
@@ -44,11 +44,11 @@ passed.
 gitURL - URL to Git repository
 branch - Branch to checkout at
  */
-function gitClone(gitURL, branch) {
-    var cloneCallback;          // Resultant callback
-    var tmpSubDir;              // Temporary sub-directory
-    var tmpDir;                 // Temporary directory
-    var checkoutBranch;         // Branch to checkout
+function gitClone (gitURL, branch) {
+    var cloneCallback; // Resultant callback
+    var tmpSubDir; // Temporary sub-directory
+    var tmpDir; // Temporary directory
+    var checkoutBranch; // Branch to checkout
 
     checkoutBranch = branch || 'master';
     tmpSubDir = 'tmp_cordova_git_' + process.pid + '_' + (new Date()).valueOf();
@@ -61,7 +61,7 @@ function gitClone(gitURL, branch) {
 
     // Callback for Git clone
     cloneCallback.then(
-        function() {
+        function () {
             return tmpDir;
         },
         function (err) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/cordova/requirements.js
----------------------------------------------------------------------
diff --git a/src/cordova/requirements.js b/src/cordova/requirements.js
index 0d8d543..08da93c 100644
--- a/src/cordova/requirements.js
+++ b/src/cordova/requirements.js
@@ -18,7 +18,7 @@
 */
 
 var cordova_util = require('./util');
-var Q            = require('q');
+var Q = require('q');
 var CordovaError = require('cordova-common').CordovaError;
 var knownPlatforms = require('../platforms/platforms');
 
@@ -31,14 +31,13 @@ var knownPlatforms = require('../platforms/platforms');
  * @return {Promise<Object>}    Promise fullfilled with map of platforms and
  *   requirements check results for each platform.
  */
-module.exports = function check_reqs(platforms) {
-    return Q().then(function() {
-        var platforms = cordova_util.preProcessOptions(platforms).platforms;
+module.exports = function check_reqs (platforms) {
+    return Q().then(function () {
+        var platforms = cordova_util.preProcessOptions(platforms).platforms; // eslint-disable-line no-use-before-define
 
         return Q.allSettled(platforms.map(function (platform) {
             return knownPlatforms.getPlatformApi(platform).requirements();
-        }))
-        .then(function (settledChecks) {
+        })).then(function (settledChecks) {
             var res = {};
             settledChecks.reduce(function (result, settledCheck, idx) {
                 var platformName = platforms[idx];


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message