You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2017/10/20 23:55:14 UTC

[5/8] cordova-lib git commit: Fix for 'pkg is not defined' exception A global js-lint pass on the cordova-lib codebase on the 30/8/2017 caused references to the global 'package' variable in init-default.js to be renamed to 'pkg’, presumably because the c

Fix for 'pkg is not defined' exception
A global js-lint pass on the cordova-lib codebase on the 30/8/2017 caused references to the global 'package' variable in init-default.js to be renamed to 'pkg’, presumably because the cordova-lib source doesn’t declare a global variable called ‘package’ but _does_ declare a global variable called ‘pkg’ (in cordova/info.js). However in this case, the ‘package’ variable refers to the one declared in the plugman source, specifically main.js, so it should have stayed as 'package’. To test the fix, run:

	plugman createpackagejson .

Without the fix, this will trigger the following exception: 'pkg is not defined'. Having patched in the fix, running the command line should work as expected, prompting the user with questions and then spitting out a package.json file.


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

Branch: refs/heads/master
Commit: e38839de40ac46f7c9dc72935b35bec308cd36d4
Parents: 57ddb90
Author: Roland <ro...@fraction7.com>
Authored: Mon Oct 16 21:57:59 2017 +0100
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Oct 20 16:46:21 2017 -0700

----------------------------------------------------------------------
 src/plugman/init-defaults.js | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e38839de/src/plugman/init-defaults.js
----------------------------------------------------------------------
diff --git a/src/plugman/init-defaults.js b/src/plugman/init-defaults.js
index f3c5ada..143bf01 100644
--- a/src/plugman/init-defaults.js
+++ b/src/plugman/init-defaults.js
@@ -19,7 +19,7 @@
 
 /* global dirname */
 /* global config */
-/* global pkg */
+/* global package */
 /* global basename */
 /* global yes */
 /* global prompt */
@@ -55,17 +55,17 @@ function readDeps (test) {
     };
 }
 
-var name = pkg.name || defaults.id || basename;
+var name = package.name || defaults.id || basename;
 exports.name = yes ? name : prompt('name', name);
 
-var version = pkg.version ||
+var version = package.version ||
               defaults.version ||
               config.get('init.version') ||
               config.get('init-version') ||
               '1.0.0';
 exports.version = yes ? version : prompt('version', version);
 
-if (!pkg.description) {
+if (!package.description) {
     if (defaults.description) {
         exports.description = defaults.description;
     } else {
@@ -73,7 +73,7 @@ if (!pkg.description) {
     }
 }
 
-if (!pkg.cordova) {
+if (!package.cordova) {
     exports.cordova = {};
     if (defaults.id) {
         exports.cordova.id = defaults.id;
@@ -83,15 +83,15 @@ if (!pkg.cordova) {
     }
 }
 
-if (!pkg.dependencies) {
+if (!package.dependencies) {
     exports.dependencies = readDeps(false);
 }
 
-if (!pkg.devDependencies) {
+if (!package.devDependencies) {
     exports.devDependencies = readDeps(true);
 }
 
-if (!pkg.repository) {
+if (!package.repository) {
     exports.repository = function (cb) {
         fs.readFile('.git/config', 'utf8', function (er, gconf) {
             if (er || !gconf) {
@@ -116,7 +116,7 @@ if (!pkg.repository) {
     };
 }
 
-if (!pkg.keywords) {
+if (!package.keywords) {
     if (defaults.keywords) {
         exports.keywords = defaults.keywords;
     } else {
@@ -129,14 +129,14 @@ if (!pkg.keywords) {
     }
 }
 
-if (!pkg.engines) {
+if (!package.engines) {
     if (defaults.engines && defaults.engines.length > 0) {
         exports.engines = defaults.engines;
     }
 }
 
 /* eslint-disable indent */
-if (!pkg.author) {
+if (!package.author) {
     exports.author = (config.get('init.author.name') ||
                      config.get('init-author-name')) ?
     {
@@ -150,7 +150,7 @@ if (!pkg.author) {
         : prompt('author');
 }
 /* eslint-enable indent */
-var license = pkg.license ||
+var license = package.license ||
               defaults.license ||
               config.get('init.license') ||
               config.get('init-license') ||


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