You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/06/18 19:07:37 UTC

[2/2] git commit: CB-6973: Fix JSHint errors in src/cordova/*.js

CB-6973: Fix JSHint errors in src/cordova/*.js

Add JSHint config comment in all the files (sometimes with tweaks)
/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
          indent:4, unused:vars, latedef:nofunc
*/

JSHint is now happy for all of src/cordova/*.js (not including metadata/*.js).


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/6748b0a6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/6748b0a6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/6748b0a6

Branch: refs/heads/master
Commit: 6748b0a65ada025debcd881cc2cc30dc74d1383f
Parents: fb41e64
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Wed Jun 18 10:57:54 2014 -0400
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Wed Jun 18 13:07:07 2014 -0400

----------------------------------------------------------------------
 cordova-lib/src/cordova/build.js         |   6 +-
 cordova-lib/src/cordova/compile.js       |   5 +-
 cordova-lib/src/cordova/config.js        |   6 +-
 cordova-lib/src/cordova/cordova.js       |   7 +-
 cordova-lib/src/cordova/create.js        |   9 +-
 cordova-lib/src/cordova/emulate.js       |   5 +-
 cordova-lib/src/cordova/hooker.js        |  39 +++++---
 cordova-lib/src/cordova/info.js          |  23 +++--
 cordova-lib/src/cordova/platforms.js     |   6 +-
 cordova-lib/src/cordova/plugin.js        |  20 ++--
 cordova-lib/src/cordova/plugin_parser.js |   8 +-
 cordova-lib/src/cordova/prepare.js       | 126 +++++++++++++-------------
 cordova-lib/src/cordova/restore.js       |  71 ++++++++-------
 cordova-lib/src/cordova/run.js           |   9 +-
 cordova-lib/src/cordova/save.js          |  88 +++++++++---------
 cordova-lib/src/cordova/serve.js         |  88 ++++++++++--------
 cordova-lib/src/cordova/superspawn.js    |   6 +-
 17 files changed, 291 insertions(+), 231 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/build.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/build.js b/cordova-lib/src/cordova/build.js
index 16b31ac..384d9e2 100644
--- a/cordova-lib/src/cordova/build.js
+++ b/cordova-lib/src/cordova/build.js
@@ -16,8 +16,12 @@
     specific language governing permissions and limitations
     under the License.
 */
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var cordova_util      = require('./util'),
-    Q                 = require('q'),
     hooker            = require('./hooker');
 
 // Returns a promise.

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/compile.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/compile.js b/cordova-lib/src/cordova/compile.js
index 857c3a5..814d3eb 100644
--- a/cordova-lib/src/cordova/compile.js
+++ b/cordova-lib/src/cordova/compile.js
@@ -17,8 +17,9 @@
     under the License.
 */
 
-/*global require: true, module: true, process: true*/
-/*jslint sloppy: true, white: true, newcap: true */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
 
 var path              = require('path'),
     cordova_util      = require('./util'),

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/config.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/config.js b/cordova-lib/src/cordova/config.js
index d0c8d9a..a92b10a 100644
--- a/cordova-lib/src/cordova/config.js
+++ b/cordova-lib/src/cordova/config.js
@@ -17,6 +17,10 @@
     under the License.
 */
 
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var path          = require('path'),
     fs            = require('fs'),
     url           = require('url'),
@@ -37,7 +41,7 @@ function config(project_root, opts) {
         configCache[project_root] = JSON.stringify(json);
     }
     return json;
-};
+}
 
 config.setAutoPersist = function(value) {
     autoPersist = value;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/cordova.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/cordova.js b/cordova-lib/src/cordova/cordova.js
index b8a494c..95110c9 100644
--- a/cordova-lib/src/cordova/cordova.js
+++ b/cordova-lib/src/cordova/cordova.js
@@ -16,6 +16,11 @@
     specific language governing permissions and limitations
     under the License.
 */
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var cordova_events = require('../events');
 var cordova_util = require('./util');
 
@@ -45,7 +50,7 @@ exports = module.exports = {
 
 exports.findProjectRoot = function(opt_startDir) {
     return cordova_util.isCordova(opt_startDir);
-}
+};
 
 // Each of these APIs takes a final parameter that is a callback function.
 // The callback is passed the error object upon failure, or undefined upon success.

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index e5187a4..a5dee41 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -17,10 +17,13 @@
     under the License.
 */
 
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var path          = require('path'),
     fs            = require('fs'),
     shell         = require('shelljs'),
-    platforms     = require('./platforms'),
     events        = require('../events'),
     config        = require('./config'),
     lazy_load     = require('./lazy_load'),
@@ -29,8 +32,8 @@ var path          = require('path'),
     ConfigParser = require('../configparser/ConfigParser'),
     cordova_util  = require('./util');
 
-var DEFAULT_NAME = "HelloCordova",
-    DEFAULT_ID   = "io.cordova.hellocordova";
+var DEFAULT_NAME = 'HelloCordova',
+    DEFAULT_ID   = 'io.cordova.hellocordova';
 
 /**
  * Usage:

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/emulate.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/emulate.js b/cordova-lib/src/cordova/emulate.js
index e45607e..2f23197 100644
--- a/cordova-lib/src/cordova/emulate.js
+++ b/cordova-lib/src/cordova/emulate.js
@@ -17,8 +17,9 @@
     under the License.
 */
 
-/*global require: true, module: true, process: true*/
-/*jslint sloppy: true, white: true, newcap: true */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
 
 var cordova_util      = require('./util'),
     path              = require('path'),

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/hooker.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/hooker.js b/cordova-lib/src/cordova/hooker.js
index 62dde30..1e6fbe4 100644
--- a/cordova-lib/src/cordova/hooker.js
+++ b/cordova-lib/src/cordova/hooker.js
@@ -16,6 +16,11 @@
     specific language governing permissions and limitations
     under the License.
 */
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var util  = require('./util'),
     fs    = require('fs'),
     os    = require('os'),
@@ -23,8 +28,7 @@ var util  = require('./util'),
     superspawn = require('./superspawn'),
     CordovaError = require('../CordovaError'),
     Q     = require('q'),
-    path  = require('path'),
-    _ = require('underscore');
+    path  = require('path');
 
 module.exports = function hooker(root) {
     var r = util.isCordova(root);
@@ -33,16 +37,22 @@ module.exports = function hooker(root) {
 };
 
 // Returns a promise.
-module.exports.fire = function global_fire(hook, opts) {
+module.exports.fire = global_fire;
+function global_fire(hook, opts) {
     opts = opts || {};
     var handlers = events.listeners(hook);
     return execute_handlers_serially(handlers, opts);
-};
+}
 
 function compareNumbers(a, b) {
-    return isNaN (parseInt(a))
-        ? a.toLowerCase().localeCompare(b.toLowerCase ? b.toLowerCase(): b)
-        : parseInt(a) > parseInt(b) ? 1 : parseInt(a) < parseInt(b) ? -1 : 0;
+    var intA = parseInt(a);
+    var intB = parseInt(b);
+    if ( isNaN(intA) ) {
+        a = a.toLowerCase();
+        b = b.toLowerCase ? b.toLowerCase() : b;
+        return a.localeCompare(b);
+    }
+    return intA == intB ? 0 : intA > intB ? 1 : -1;
 }
 
 module.exports.prototype = {
@@ -75,12 +85,13 @@ module.exports.prototype = {
 };
 
 function extractSheBangInterpreter(fullpath) {
-    var hookFd = fs.openSync(fullpath, "r");
+    var hookFd = fs.openSync(fullpath, 'r');
+    var fileData, octetsRead, fileChunk;
     try {
         // this is a modern cluster size. no need to read less
-        var fileData = new Buffer (4096);
-        var octetsRead = fs.readSync(hookFd, fileData, 0, 4096, 0);
-        var fileChunk = fileData.toString();
+        fileData = new Buffer (4096);
+        octetsRead = fs.readSync(hookFd, fileData, 0, 4096, 0);
+        fileChunk = fileData.toString();
     } finally {
         fs.closeSync(hookFd);
     }
@@ -94,9 +105,9 @@ function extractSheBangInterpreter(fullpath) {
         hookCmd = shebangMatch[1];
     // Likewise, make /usr/bin/bash work like "bash".
     if (hookCmd)
-        shMatch = hookCmd.match(/bin\/((?:ba)?sh)$/)
+        shMatch = hookCmd.match(/bin\/((?:ba)?sh)$/);
     if (shMatch)
-        hookCmd = shMatch[1]
+        hookCmd = shMatch[1];
     return hookCmd;
 }
 
@@ -153,7 +164,7 @@ function execute_handlers_serially(handlers, opts) {
     if (handlers.length) {
         // Chain the handlers in series.
         return handlers.reduce(function(soFar, f) {
-            return soFar.then(function() { return f(opts) });
+            return soFar.then(function() { return f(opts); });
         }, Q());
     } else {
         return Q(); // Nothing to do.

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/info.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/info.js b/cordova-lib/src/cordova/info.js
index 48011de..8736a1c 100644
--- a/cordova-lib/src/cordova/info.js
+++ b/cordova-lib/src/cordova/info.js
@@ -15,7 +15,11 @@ software distributed under the License is distributed on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
- */
+*/
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
 
 /*
 A utility funciton to help output the information needed
@@ -70,15 +74,14 @@ module.exports = function info() {
             //Get Platforms information
             getPlatforms(projectRoot)
         ]).then(function(promises) {
-        promises.forEach(function(p) {
-            output += p.state === 'fulfilled' ? p.value + '\n\n' : p.reason + '\n\n';
+            promises.forEach(function(p) {
+                output += p.state === 'fulfilled' ? p.value + '\n\n' : p.reason + '\n\n';
+            });
+            console.info(output);
+            fs.writeFile(path.join(projectRoot, 'info.txt'), output, 'utf-8', function (err) {
+                if (err) throw err;
+            });
         });
-        console.info(output);
-        fs.writeFile(path.join(projectRoot, 'info.txt'), output, 'utf-8', function (err) {
-            if (err)
-                throw err;
-        });
-    });
 };
 
 function getPlatforms(projectRoot) {
@@ -87,7 +90,7 @@ function getPlatforms(projectRoot) {
         return Q.all(platforms.map(function(p) {
             return getPlatformInfo(p, projectRoot);
         })).then(function(outs) {
-          return outs.join('\n\n');
+            return outs.join('\n\n');
         });
     }
     return Q.reject('No Platforms Currently Installed');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/platforms.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platforms.js b/cordova-lib/src/cordova/platforms.js
index d9a1514..5ada624 100644
--- a/cordova-lib/src/cordova/platforms.js
+++ b/cordova-lib/src/cordova/platforms.js
@@ -17,6 +17,10 @@
     under the License.
 */
 
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 module.exports = {
     'ios' : {
         hostos : ['darwin'],
@@ -35,7 +39,7 @@ module.exports = {
         url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-ubuntu.git',
         version: '3.5.0'
     },
-     'amazon-fireos' : {
+    'amazon-fireos' : {
         parser : './metadata/amazon_fireos_parser',
         url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-amazon-fireos.git',
         version: '3.5.0'

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index 8541b21..8a792b9 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -17,7 +17,9 @@
     under the License.
 */
 
-/* jshint node: true */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
 
 var cordova_util  = require('./util'),
     path          = require('path'),
@@ -29,12 +31,12 @@ var cordova_util  = require('./util'),
     ConfigParser  = require('../configparser/ConfigParser'),
     fs            = require('fs'),
     PluginInfo    = require('../PluginInfo'),
+    plugman       = require('../plugman/plugman'),
     events        = require('../events');
 
 // Returns a promise.
 module.exports = function plugin(command, targets, opts) {
-    var projectRoot = cordova_util.cdProjectRoot(),
-        err;
+    var projectRoot = cordova_util.cdProjectRoot();
 
     // Dance with all the possible call signatures we've come up over the time. They can be:
     // 1. plugin() -> list the plugins
@@ -113,16 +115,13 @@ module.exports = function plugin(command, targets, opts) {
 
                         // Fetch the plugin first.
                         events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
-                        var plugman = require('../plugman/plugman');
                         return plugman.raw.fetch(target, pluginsDir, { searchpath: searchPath, noregistry: opts.noregistry});
                     })
                     .then(function(dir) {
                         // Iterate (in serial!) over all platforms in the project and install the plugin.
                         return platformList.reduce(function(soFar, platform) {
                             return soFar.then(function() {
-                                var platforms = require('./platforms');
                                 var platformRoot = path.join(projectRoot, 'platforms', platform),
-                                    parser = new platforms[platform].parser(platformRoot),
                                     options = {
                                         cli_variables: opts.cli_variables || {},
                                         searchpath: searchPath,
@@ -136,7 +135,7 @@ module.exports = function plugin(command, targets, opts) {
                                 // Keeping for now for compatibility for API users.
                                 //parse variables into cli_variables
                                 for (i=0; i< opts.options.length; i++) {
-                                    if (opts.options[i] === "--variable" && typeof opts.options[++i] === "string") {
+                                    if (opts.options[i] === '--variable' && typeof opts.options[++i] === 'string') {
                                         tokens = opts.options[i].split('=');
                                         key = tokens.shift().toUpperCase();
                                         if (/^[\w-_]+$/.test(key)) {
@@ -154,7 +153,6 @@ module.exports = function plugin(command, targets, opts) {
             }).then(function() {
                 return hooks.fire('after_plugin_add', opts);
             });
-            break;
         case 'rm':
         case 'remove':
             if (!targets || !targets.length) {
@@ -168,7 +166,6 @@ module.exports = function plugin(command, targets, opts) {
                         return Q.reject(new CordovaError('Plugin "' + target + '" is not present in the project. See `'+cordova_util.binname+' plugin list`.'));
                     }
 
-                    var targetPath = path.join(pluginPath, target);
                     // 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
@@ -177,8 +174,6 @@ module.exports = function plugin(command, targets, opts) {
                     return platformList.reduce(function(soFar, platform) {
                         return soFar.then(function() {
                             var platformRoot = path.join(projectRoot, 'platforms', platform);
-                            var platforms = require('./platforms');
-                            var parser = new platforms[platform].parser(platformRoot);
                             //check if plugin is restorable and warn
                             var configPath = cordova_util.projectConfig(projectRoot);
                             if(fs.existsSync(configPath)){//should not happen with real life but needed for tests
@@ -199,7 +194,6 @@ module.exports = function plugin(command, targets, opts) {
             }).then(function() {
                 return hooks.fire('after_plugin_rm', opts);
             });
-            break;
         case 'search':
             return hooks.fire('before_plugin_search')
             .then(function() {
@@ -212,8 +206,6 @@ module.exports = function plugin(command, targets, opts) {
             }).then(function() {
                 return hooks.fire('after_plugin_search');
             });
-        case 'ls':
-        case 'list':
         default:
             return list(projectRoot, hooks);
     }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/plugin_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin_parser.js b/cordova-lib/src/cordova/plugin_parser.js
index d86536b..38eaebc 100644
--- a/cordova-lib/src/cordova/plugin_parser.js
+++ b/cordova-lib/src/cordova/plugin_parser.js
@@ -16,8 +16,12 @@
     specific language governing permissions and limitations
     under the License.
 */
-var xml = require('../util/xml-helpers'),
-    fs  = require('fs');
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
+var xml = require('../util/xml-helpers');
 
 function plugin_parser(xmlPath) {
     this.path = xmlPath;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/prepare.js b/cordova-lib/src/cordova/prepare.js
index fadb39c..be48c51 100644
--- a/cordova-lib/src/cordova/prepare.js
+++ b/cordova-lib/src/cordova/prepare.js
@@ -16,11 +16,15 @@
     specific language governing permissions and limitations
     under the License.
 */
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var cordova_util      = require('./util'),
     ConfigParser      = require('../configparser/ConfigParser'),
     path              = require('path'),
     platforms         = require('./platforms'),
-    platform          = require('./platform'),
     fs                = require('fs'),
     shell             = require('shelljs'),
     et                = require('elementtree'),
@@ -28,8 +32,7 @@ var cordova_util      = require('./util'),
     lazy_load         = require('./lazy_load'),
     events            = require('../events'),
     Q                 = require('q'),
-    plugman           = require('../plugman/plugman'),
-    util              = require('util');
+    plugman           = require('../plugman/plugman');
 
 // Returns a promise.
 exports = module.exports = function prepare(options) {
@@ -64,18 +67,18 @@ exports = module.exports = function prepare(options) {
             return lazy_load.based_on_config(projectRoot, platform)
             .then(function(libDir) {
                 var parser = new platforms[platform].parser(platformPath),
-                    defaults_xml_path = path.join(platformPath, "cordova", "defaults.xml");
+                    defaults_xml_path = path.join(platformPath, 'cordova', 'defaults.xml');
                 //If defaults.xml is present, overwrite platform config.xml with it
                 //Otherwise save whatever is there as defaults so it can be restored
                 //or copy project config into platform if none exists
                 if (fs.existsSync(defaults_xml_path)) {
-                    shell.cp("-f", defaults_xml_path, parser.config_xml());
+                    shell.cp('-f', defaults_xml_path, parser.config_xml());
                     events.emit('verbose', 'Generating config.xml from defaults for platform "' + platform + '"');
                 } else {
                     if(fs.existsSync(parser.config_xml())){
-                        shell.cp("-f", parser.config_xml(), defaults_xml_path);
+                        shell.cp('-f', parser.config_xml(), defaults_xml_path);
                     }else{
-                        shell.cp("-f",xml,parser.config_xml());
+                        shell.cp('-f',xml,parser.config_xml());
                     }
                 }
 
@@ -118,66 +121,61 @@ exports = module.exports = function prepare(options) {
     });
 };
 
-var BLACKLIST = ["platform"];
-var SINGLETONS = ["content", "author"];
+var BLACKLIST = ['platform'];
+var SINGLETONS = ['content', 'author'];
 function mergeXml(src, dest, platform, clobber) {
-    if (BLACKLIST.indexOf(src.tag) === -1) {
-        //Handle attributes
-        Object.getOwnPropertyNames(src.attrib).forEach(function (attribute) {
-            if (clobber || !dest.attrib[attribute]) {
-                dest.attrib[attribute] = src.attrib[attribute];
-            }
-        });
-        //Handle text
-        if (src.text && (clobber || !dest.text)) {
-            dest.text = src.text;
-        }
-        //Handle platform
-        if (platform) {
-            src.findall('platform[@name="' + platform + '"]').forEach(function (platformElement) {
-                platformElement.getchildren().forEach(mergeChild);
-            });
+    // Do nothing for blacklisted tags.
+    if (BLACKLIST.indexOf(src.tag) != -1) return;
+
+    //Handle attributes
+    Object.getOwnPropertyNames(src.attrib).forEach(function (attribute) {
+        if (clobber || !dest.attrib[attribute]) {
+            dest.attrib[attribute] = src.attrib[attribute];
         }
+    });
+    //Handle text
+    if (src.text && (clobber || !dest.text)) {
+        dest.text = src.text;
+    }
+    //Handle platform
+    if (platform) {
+        src.findall('platform[@name="' + platform + '"]').forEach(function (platformElement) {
+            platformElement.getchildren().forEach(mergeChild);
+        });
+    }
 
-        //Handle children
-        src.getchildren().forEach(mergeChild);
-
-        function mergeChild (srcChild) {
-            var srcTag = srcChild.tag,
-                destChild = new et.Element(srcTag),
-                foundChild,
-                query = srcTag + "",
-                shouldMerge = true;
-
-            if (BLACKLIST.indexOf(srcTag) === -1) {
-                if (SINGLETONS.indexOf(srcTag) !== -1) {
-                    foundChild = dest.find(query);
-                    if (foundChild) {
-                        destChild = foundChild;
-                        dest.remove(0, destChild);
-                    }
-                } else {
-                    //Check for an exact match and if you find one don't add
-                    Object.getOwnPropertyNames(srcChild.attrib).forEach(function (attribute) {
-                        query += "[@" + attribute + '="' + srcChild.attrib[attribute] + '"]';
-                    });
-                    foundChild = dest.find(query);
-                    if (foundChild && textMatch(srcChild, foundChild)) {
-                        destChild = foundChild;
-                        dest.remove(0, destChild);
-                        shouldMerge = false;
-                    }
+    //Handle children
+    src.getchildren().forEach(mergeChild);
+
+    function mergeChild (srcChild) {
+        var srcTag = srcChild.tag,
+            destChild = new et.Element(srcTag),
+            foundChild,
+            query = srcTag + '',
+            shouldMerge = true;
+
+        if (BLACKLIST.indexOf(srcTag) === -1) {
+            if (SINGLETONS.indexOf(srcTag) !== -1) {
+                foundChild = dest.find(query);
+                if (foundChild) {
+                    destChild = foundChild;
+                    dest.remove(0, destChild);
+                }
+            } else {
+                //Check for an exact match and if you find one don't add
+                Object.getOwnPropertyNames(srcChild.attrib).forEach(function (attribute) {
+                    query += '[@' + attribute + '="' + srcChild.attrib[attribute] + '"]';
+                });
+                foundChild = dest.find(query);
+                if (foundChild && textMatch(srcChild, foundChild)) {
+                    destChild = foundChild;
+                    dest.remove(0, destChild);
+                    shouldMerge = false;
                 }
-
-                mergeXml(srcChild, destChild, platform, clobber && shouldMerge);
-                dest.append(destChild);
             }
-        }
 
-        function textMatch(elm1, elm2) {
-            var text1 = elm1.text ? elm1.text.replace(/\s+/, "") : "",
-                text2 = elm2.text ? elm2.text.replace(/\s+/, "") : "";
-            return (text1 === "" || text1 === text2);
+            mergeXml(srcChild, destChild, platform, clobber && shouldMerge);
+            dest.append(destChild);
         }
     }
 }
@@ -185,3 +183,9 @@ function mergeXml(src, dest, platform, clobber) {
 // Expose for testing.
 exports._mergeXml = mergeXml;
 
+
+function textMatch(elm1, elm2) {
+    var text1 = elm1.text ? elm1.text.replace(/\s+/, '') : '',
+        text2 = elm2.text ? elm2.text.replace(/\s+/, '') : '';
+    return (text1 === '' || text1 === text2);
+}

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/restore.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/restore.js b/cordova-lib/src/cordova/restore.js
index 0d56b4a..2ef3f66 100644
--- a/cordova-lib/src/cordova/restore.js
+++ b/cordova-lib/src/cordova/restore.js
@@ -17,16 +17,20 @@
     under the License.
 */
 
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var cordova_util    = require('./util'),
     ConfigParser     = require('../configparser/ConfigParser'),
     path             = require('path'),
-    xml              = require('../util/xml-helpers')
     Q                = require('q'),
     fs               = require('fs'),
     plugin           = require('./plugin'),
     events           = require('../events');
 
-module.exports = function restore(target){
+module.exports = restore;
+function restore(target){
     var projectHome = cordova_util.cdProjectRoot();
     var configPath = cordova_util.projectConfig(projectHome);
     var configXml = new ConfigParser(configPath);
@@ -35,42 +39,41 @@ module.exports = function restore(target){
 
 
 //returns a Promise
-function installPluginsFromConfigXML(cfg){
-        //Install plugins that are listed on config.xml
-        var pluginsFromConfig = new Array();
-        var projectRoot = cordova_util.cdProjectRoot();
-        var plugins_dir = path.join(projectRoot, 'plugins');
+function installPluginsFromConfigXML(cfg) {
+    //Install plugins that are listed on config.xml
+    var pluginsFromConfig = [];
+    var projectRoot = cordova_util.cdProjectRoot();
+    var plugins_dir = path.join(projectRoot, 'plugins');
 
-        var features = cfg.doc.findall('feature');
-        features.forEach(function(feature){
-          var params = feature.findall('param');
-          var pluginId = "";
-          var pluginVersion = "";
-          for( var i =0; i < params.length; i++){
-            if(params[i].attrib.name === 'id'){
-              pluginId = params[i].attrib.value;
+    var features = cfg.doc.findall('feature');
+    features.forEach(function(feature){
+        var params = feature.findall('param');
+        var pluginId = '';
+        var pluginVersion = '';
+        for (var i = 0; i < params.length; i++) {
+            if (params[i].attrib.name === 'id') {
+                pluginId = params[i].attrib.value;
             }
-            if(params[i].attrib.name === 'version'){
-              pluginVersion = params[i].attrib.value;
+            if (params[i].attrib.name === 'version') {
+                pluginVersion = params[i].attrib.value;
             }
-          }
-          var pluginPath =  path.join(plugins_dir,pluginId);
-          // contents of the plugins folder takes precedence hence
-          // we ignore if the correct version is installed or not.
-          if(pluginId !== "" && !fs.existsSync(pluginPath)){
-            if( pluginVersion !== ""){
-              pluginId = pluginId +"@"+pluginVersion;
+        }
+        var pluginPath =  path.join(plugins_dir,pluginId);
+        // contents of the plugins folder takes precedence hence
+        // we ignore if the correct version is installed or not.
+        if (pluginId !== '' && !fs.existsSync(pluginPath)) {
+            if ( pluginVersion !== '') {
+                pluginId = pluginId + '@' + pluginVersion;
             }
-            events.emit('log', "Discovered "+ pluginId + " in config.xml. Installing to the project")
+            events.emit('log', 'Discovered ' + pluginId + ' in config.xml. Installing to the project');
             pluginsFromConfig.push(pluginId);
-          }
-
-        })
-
-        //Use cli instead of plugman directly ensuring all the hooks
-        // to get fired.
-        if(pluginsFromConfig.length >0){
-            return plugin("add",pluginsFromConfig);
         }
-        return Q.all("No config.xml plugins to install");
+    });
+
+    //Use cli instead of plugman directly ensuring all the hooks
+    // to get fired.
+    if (pluginsFromConfig.length >0) {
+        return plugin('add', pluginsFromConfig);
+    }
+    return Q.all('No config.xml plugins to install');
 }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/run.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/run.js b/cordova-lib/src/cordova/run.js
index 424fa58..f1debb6 100644
--- a/cordova-lib/src/cordova/run.js
+++ b/cordova-lib/src/cordova/run.js
@@ -17,8 +17,9 @@
     under the License.
 */
 
-/*global require: true, module: true, process: true*/
-/*jslint sloppy: true, white: true, newcap: true */
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
 
 var cordova_util      = require('./util'),
     path              = require('path'),
@@ -28,14 +29,14 @@ var cordova_util      = require('./util'),
 
 // Returns a promise.
 module.exports = function run(options) {
-    var projectRoot = cordova_util.cdProjectRoot(),
+    var projectRoot = cordova_util.cdProjectRoot();
     options = cordova_util.preProcessOptions(options);
 
     var hooks = new hooker(projectRoot);
     return hooks.fire('before_run', options)
     .then(function() {
         // Run a prepare first, then shell out to run
-        return require('./cordova').raw.prepare(options.platforms)
+        return require('./cordova').raw.prepare(options.platforms);
     }).then(function() {
         // Deploy in parallel (output gets intermixed though...)
         return Q.all(options.platforms.map(function(platform) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/save.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/save.js b/cordova-lib/src/cordova/save.js
index 8165058..af0460b 100644
--- a/cordova-lib/src/cordova/save.js
+++ b/cordova-lib/src/cordova/save.js
@@ -17,52 +17,58 @@
     under the License.
 */
 
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
+
 var cordova_util    = require('./util'),
     ConfigParser     = require('../configparser/ConfigParser'),
     path             = require('path'),
-    xml              = require('../util/xml-helpers')
+    xml              = require('../util/xml-helpers'),
     Q                = require('q'),
     events           = require('../events');
 
-module.exports = function save(target, opts){
-  opts = opts || {};
-  var projectHome = cordova_util.cdProjectRoot();
-  var configPath = cordova_util.projectConfig(projectHome);
-  var configXml = new ConfigParser(configPath);
-  var pluginsPath = path.join(projectHome, 'plugins');
-  var plugins = cordova_util.findPlugins(pluginsPath);
-  var features = configXml.doc.findall('./feature/param[@name="id"]/..');
-  //clear obsolete features with id params.
-  for(var i=0; i<features.length; i++){
-     //somehow elementtree remove fails on me
-     var childs = configXml.doc.getroot().getchildren();
-     var idx = childs.indexOf(features[i]);
-     if(idx > -1){
-        childs.splice(idx,1);
-      }
-  }
-  // persist the removed features here if there are no plugins
-  // to be added to config.xml otherwise we can delay the
-  // persist to add feature
-  if((!plugins || plugins.length<1) &&
-        (features && features.length)){
-      configXml.write();
-  }
-
-  return Q.all(plugins.map(function(plugin){
-    var currentPluginPath = path.join(pluginsPath,plugin);
-    var name = readPluginName(currentPluginPath);
-    var id = plugin;
-    var version = readPluginVersion(currentPluginPath);
-    var params = [{name:"id", value:id}];
-    if(opts.shrinkwrap){
-        params.push({name:"version", value: version});
+module.exports = save;
+function save(target, opts){
+    opts = opts || {};
+    var projectHome = cordova_util.cdProjectRoot();
+    var configPath = cordova_util.projectConfig(projectHome);
+    var configXml = new ConfigParser(configPath);
+    var pluginsPath = path.join(projectHome, 'plugins');
+    var plugins = cordova_util.findPlugins(pluginsPath);
+    var features = configXml.doc.findall('./feature/param[@name="id"]/..');
+    //clear obsolete features with id params.
+    for(var i=0; i<features.length; i++){
+        //somehow elementtree remove fails on me
+        var childs = configXml.doc.getroot().getchildren();
+        var idx = childs.indexOf(features[i]);
+        if(idx > -1){
+            childs.splice(idx,1);
+        }
+    }
+    // persist the removed features here if there are no plugins
+    // to be added to config.xml otherwise we can delay the
+    // persist to add feature
+    if((!plugins || plugins.length<1) &&
+          (features && features.length)){
+        configXml.write();
     }
-    configXml.addFeature(name,params);
-    configXml.write();
-    events.emit('results', 'Saved plugin info for "'+plugin+'" to config.xml');
-    return Q();
-  }));
+
+    return Q.all(plugins.map(function(plugin){
+        var currentPluginPath = path.join(pluginsPath,plugin);
+        var name = readPluginName(currentPluginPath);
+        var id = plugin;
+        var version = readPluginVersion(currentPluginPath);
+        var params = [{name:'id', value:id}];
+        if(opts.shrinkwrap){
+            params.push({ name: 'version', value: version });
+        }
+        configXml.addFeature(name,params);
+        configXml.write();
+        events.emit('results', 'Saved plugin info for "'+plugin+'" to config.xml');
+        return Q();
+    }));
 }
 
 function readPluginName(pluginPath){
@@ -70,9 +76,9 @@ function readPluginName(pluginPath){
     var et = xml.parseElementtreeSync(xml_path);
     var el = et.getroot().find('name');
     if(el && el.text){
-       return el.text.trim();
+        return el.text.trim();
     }
-    return "";
+    return '';
 }
 
 function readPluginVersion(pluginPath){

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/serve.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/serve.js b/cordova-lib/src/cordova/serve.js
index 8a4eb5c..60522d1 100644
--- a/cordova-lib/src/cordova/serve.js
+++ b/cordova-lib/src/cordova/serve.js
@@ -16,6 +16,11 @@
     specific language governing permissions and limitations
     under the License.
 */
+
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var cordova_util = require('./util'),
     crypto = require('crypto'),
     path = require('path'),
@@ -24,56 +29,60 @@ var cordova_util = require('./util'),
     ConfigParser = require('../configserver/ConfigParser'),
     hooker        = require('./hooker'),
     fs = require('fs'),
-    http = require("http"),
-    url = require("url"),
-    mime = require("mime"),
-    zlib = require("zlib");
+    http = require('http'),
+    url = require('url'),
+    mime = require('mime'),
+    zlib = require('zlib');
 
 function launchServer(projectRoot, port) {
     var server = http.createServer(function(request, response) {
         function do404() {
             console.log('404 ' + request.url);
-            response.writeHead(404, {"Content-Type": "text/plain"});
-            response.write("404 Not Found\n");
+            response.writeHead(404, {'Content-Type': 'text/plain'});
+            response.write('404 Not Found\n');
             response.end();
         }
         function do302(where) {
             console.log('302 ' + request.url);
-            response.setHeader("Location", where);
-            response.writeHead(302, {"Content-Type": "text/plain"});
+            response.setHeader('Location', where);
+            response.writeHead(302, {'Content-Type': 'text/plain'});
             response.end();
         }
         function doRoot() {
-            response.writeHead(200, {"Content-Type": "text/html"});
+            var p;
+            response.writeHead(200, {'Content-Type': 'text/html'});
             var config = new ConfigParser(cordova_util.projectConfig(projectRoot));
-            response.write("<html><head><title>"+config.name()+"</title></head><body>");
-            response.write("<table border cellspacing=0><thead><caption><h3>Package Metadata</h3></caption></thead><tbody>");
-            for (var c in {"name": true, "packageName": true, "version": true}) {
-                response.write("<tr><th>"+c+"</th><td>"+config[c]()+"</td></tr>");
+            response.write('<html><head><title>'+config.name()+'</title></head><body>');
+            response.write('<table border cellspacing=0><thead><caption><h3>Package Metadata</h3></caption></thead><tbody>');
+            for (var c in {'name': true, 'packageName': true, 'version': true}) {
+                response.write('<tr><th>' + c + '</th><td>' + config[c]() + '</td></tr>');
             }
-            response.write("</tbody></table>");
-            response.write("<h3>Platforms</h3><ul>");
+            response.write('</tbody></table>');
+            response.write('<h3>Platforms</h3><ul>');
             var installed_platforms = cordova_util.listPlatforms(projectRoot);
-            for (var p in platforms) {
+            for (p in platforms) {
                 if (installed_platforms.indexOf(p) >= 0) {
-                    response.write("<li><a href='"+p+"/'>"+p+"</a></li>\n");
+                    response.write('<li><a href="' + p + '/">' + p + '</a></li>\n');
                 } else {
-                    response.write("<li><em>"+p+"</em></li>\n");
+                    response.write('<li><em>' + p + '</em></li>\n');
                 }
             }
-            response.write("</ul>");
-            response.write("<h3>Plugins</h3><ul>");
+            response.write('</ul>');
+            response.write('<h3>Plugins</h3><ul>');
             var pluginPath = path.join(projectRoot, 'plugins');
             var plugins = cordova_util.findPlugins(pluginPath);
-            for (var p in plugins) {
-                response.write("<li>"+plugins[p]+"</li>\n");
+            for (p in plugins) {
+                response.write('<li>'+plugins[p]+'</li>\n');
             }
-            response.write("</ul>");
-            response.write("</body></html>");
+            response.write('</ul>');
+            response.write('</body></html>');
             response.end();
         }
+
         var urlPath = url.parse(request.url).pathname;
         var firstSegment = /\/(.*?)\//.exec(urlPath);
+        var parser;
+
         if (!firstSegment) {
             return doRoot();
         }
@@ -85,7 +94,7 @@ function launchServer(projectRoot, port) {
         urlPath = urlPath.slice(platformId.length + 1);
 
         try {
-            var parser = new platforms[platformId].parser(path.join(projectRoot, 'platforms', platformId));
+            parser = new platforms[platformId].parser(path.join(projectRoot, 'platforms', platformId));
         } catch (e) {
             return do404();
         }
@@ -99,7 +108,7 @@ function launchServer(projectRoot, port) {
         } else if (/^\/www\//.test(urlPath)) {
             filePath = path.join(parser.www_dir(), urlPath.slice(5));
         } else if (/^\/+[^\/]*$/.test(urlPath)) {
-            return do302("/" + platformId + "/www/");
+            return do302('/' + platformId + '/www/');
         } else {
             return do404();
         }
@@ -107,7 +116,7 @@ function launchServer(projectRoot, port) {
         fs.exists(filePath, function(exists) {
             if (exists) {
                 if (fs.statSync(filePath).isDirectory()) {
-                    index = path.join(filePath, "index.html");
+                    var index = path.join(filePath, 'index.html');
                     try {
                         if (fs.statSync(index)) {
                             filePath = index;
@@ -116,26 +125,26 @@ function launchServer(projectRoot, port) {
                 }
                 if (fs.statSync(filePath).isDirectory()) {
                     if (!/\/$/.test(urlPath)) {
-                        return do302("/" + platformId + urlPath + "/");
+                        return do302('/' + platformId + urlPath + '/');
                     }
                     console.log('200 ' + request.url);
-                    response.writeHead(200, {"Content-Type": "text/html"});
-                    response.write("<html><head><title>Directory listing of "+ urlPath + "</title></head>");
-                    response.write("<h3>Items in this directory</h3>");
+                    response.writeHead(200, {'Content-Type': 'text/html'});
+                    response.write('<html><head><title>Directory listing of '+ urlPath + '</title></head>');
+                    response.write('<h3>Items in this directory</h3>');
                     var items = fs.readdirSync(filePath);
-                    response.write("<ul>");
+                    response.write('<ul>');
                     for (var i in items) {
                         var file = items[i];
                         if (file) {
                             response.write('<li><a href="'+file+'">'+file+'</a></li>\n');
                         }
                     }
-                    response.write("</ul>");
+                    response.write('</ul>');
                     response.end();
                 } else {
                     var mimeType = mime.lookup(filePath);
                     var respHeaders = {
-                      'Content-Type': mimeType
+                        'Content-Type': mimeType
                     };
                     var readStream = fs.createReadStream(filePath);
 
@@ -156,27 +165,28 @@ function launchServer(projectRoot, port) {
             }
         });
     }).on('listening', function () {
-        console.log("Static file server running on port " + port + " (i.e. http://localhost:" + port + ")\nCTRL + C to shut down");
+        console.log('Static file server running on port ' + port + ' (i.e. http://localhost:' + port + ')\nCTRL + C to shut down');
     }).on('error', function (e) {
         if (e && e.toString().indexOf('EADDRINUSE') !== -1) {
             port++;
             server.listen(port);
         } else {
-            console.log("An error occured starting static file server: " + e);
+            console.log('An error occured starting static file server: ' + e);
         }
     }).listen(port);
     return server;
 }
 
 function calculateMd5(fileName) {
-    var BUF_LENGTH = 64*1024,
+    var md5sum,
+        BUF_LENGTH = 64*1024,
         buf = new Buffer(BUF_LENGTH),
         bytesRead = BUF_LENGTH,
         pos = 0,
         fdr = fs.openSync(fileName, 'r');
 
     try {
-        var md5sum = crypto.createHash('md5');
+        md5sum = crypto.createHash('md5');
         while (bytesRead === BUF_LENGTH) {
             bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
             pos += bytesRead;
@@ -195,7 +205,7 @@ function processAddRequest(request, response, platformId, projectRoot) {
         'configPath': '/' + platformId + '/config.xml',
         'wwwPath': '/' + platformId + '/www',
         'wwwFileList': shell.find(wwwDir)
-            .filter(function(a) { return !fs.statSync(a).isDirectory() && !/(^\.)|(\/\.)/.test(a) })
+            .filter(function(a) { return !fs.statSync(a).isDirectory() && !/(^\.)|(\/\.)/.test(a); })
             .map(function(a) { return {'path': a.slice(wwwDir.length), 'etag': '' + calculateMd5(a)}; })
     };
     console.log('200 ' + request.url);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6748b0a6/cordova-lib/src/cordova/superspawn.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/superspawn.js b/cordova-lib/src/cordova/superspawn.js
index 3b14e4b..b35e311 100644
--- a/cordova-lib/src/cordova/superspawn.js
+++ b/cordova-lib/src/cordova/superspawn.js
@@ -17,6 +17,10 @@
     under the License.
 */
 
+/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc
+*/
+
 var child_process = require('child_process');
 var fs = require('fs');
 var path = require('path');
@@ -74,7 +78,7 @@ exports.spawn = function(cmd, args, opts) {
         // but for things like "del", cmd will do the trick.
         if (path.extname(cmd) != '.exe' && cmd.indexOf(' ') != -1) {
             // We need to use /s to ensure that spaces are parsed properly with cmd spawned content
-            args = [['/s', '/c', '"'+[cmd].concat(args).map(function(a){if (/^[^"].* .*[^"]/.test(a)) return '"'+a+'"'; return a;}).join(" ")+'"'].join(" ")];
+            args = [['/s', '/c', '"' + [cmd].concat(args).map(function(a){if (/^[^"].* .*[^"]/.test(a)) return '"' + a + '"'; return a;}).join(' ')+'"'].join(' ')];
             cmd = 'cmd';
             spawnOpts.windowsVerbatimArguments = true;
         } else if (!fs.existsSync(cmd)) {