You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/04/15 01:09:54 UTC
[cordova-lib] branch master updated: Make
src/plugman/init-defaults.js lintable (#774)
This is an automated email from the ASF dual-hosted git repository.
raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-lib.git
The following commit(s) were added to refs/heads/master by this push:
new 0ad8e95 Make src/plugman/init-defaults.js lintable (#774)
0ad8e95 is described below
commit 0ad8e95a36583fcba2838fb7761b31053986c1fb
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Mon Apr 15 03:09:49 2019 +0200
Make src/plugman/init-defaults.js lintable (#774)
Work around using the reserved word `package` to be able to lint
src/plugman/init-defaults.js
---
.eslintignore | 1 -
src/plugman/init-defaults.js | 27 +++++++++++++++------------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/.eslintignore b/.eslintignore
index 88966f0..e0bfbb1 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,5 +1,4 @@
coverage/
-src/plugman/init-defaults.js
spec/cordova/fixtures/*
spec/plugman/projects/*
spec/plugman/plugins/*
diff --git a/src/plugman/init-defaults.js b/src/plugman/init-defaults.js
index 93bbbfe..222946d 100644
--- a/src/plugman/init-defaults.js
+++ b/src/plugman/init-defaults.js
@@ -19,12 +19,15 @@
/* global dirname */
/* global config */
-/* global package */
/* global basename */
/* global yes */
/* global prompt */
// PromZard file that is used by createpackagejson and init-package-json module
+// The PromZard context is also provided via this. Make use of this to avoid
+// having to use the reserved word package. This way we can lint this file.
+const pkg = this.package;
+
var fs = require('fs-extra');
var path = require('path');
var defaults = require('./defaults.json');
@@ -55,17 +58,17 @@ function readDeps (test) {
};
}
-var name = package.name || defaults.id || basename;
+var name = pkg.name || defaults.id || basename;
exports.name = yes ? name : prompt('name', name);
-var version = package.version ||
+var version = pkg.version ||
defaults.version ||
config.get('init.version') ||
config.get('init-version') ||
'1.0.0';
exports.version = yes ? version : prompt('version', version);
-if (!package.description) {
+if (!pkg.description) {
if (defaults.description) {
exports.description = defaults.description;
} else {
@@ -73,7 +76,7 @@ if (!package.description) {
}
}
-if (!package.cordova) {
+if (!pkg.cordova) {
exports.cordova = {};
if (defaults.id) {
exports.cordova.id = defaults.id;
@@ -83,15 +86,15 @@ if (!package.cordova) {
}
}
-if (!package.dependencies) {
+if (!pkg.dependencies) {
exports.dependencies = readDeps(false);
}
-if (!package.devDependencies) {
+if (!pkg.devDependencies) {
exports.devDependencies = readDeps(true);
}
-if (!package.repository) {
+if (!pkg.repository) {
exports.repository = function (cb) {
fs.readFile('.git/config', 'utf8', function (er, gconf) {
if (er || !gconf) {
@@ -116,7 +119,7 @@ if (!package.repository) {
};
}
-if (!package.keywords) {
+if (!pkg.keywords) {
if (defaults.keywords) {
exports.keywords = defaults.keywords;
} else {
@@ -129,13 +132,13 @@ if (!package.keywords) {
}
}
-if (!package.engines) {
+if (!pkg.engines) {
if (defaults.engines && defaults.engines.length > 0) {
exports.engines = defaults.engines;
}
}
-if (!package.author) {
+if (!pkg.author) {
exports.author = (config.get('init.author.name') ||
config.get('init-author-name')) ?
{
@@ -148,7 +151,7 @@ if (!package.author) {
}
: prompt('author');
}
-var license = package.license ||
+var license = pkg.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