Skip to content
Permalink
Browse files
Remove futile attempts to read npm config values
Our init-defaults.js apparently is a slightly modified copy of
init-package-json/default-input.js. When npm calls `init-package-json`
they probably pass an object parsed from their configuration file.

We on the other hand always pass `{}`. Which means that any call to
`config.get` will return `undefined`.

This commit replaces all these calls in our code with `undefined` and
does some constant folding to tidy things up.
  • Loading branch information
raphinesse committed Apr 15, 2019
1 parent 0ad8e95 commit 2d9f1012b13c13c58d3179e73595051ac9e0e396
Showing 1 changed file with 4 additions and 23 deletions.
@@ -18,7 +18,6 @@
**/

/* global dirname */
/* global config */
/* global basename */
/* global yes */
/* global prompt */
@@ -47,7 +46,7 @@ function readDeps (test) {
if (er) return next();
try { p = JSON.parse(p); } catch (e) { return next(); }
if (!p.version) return next();
deps[d] = config.get('save-exact') ? p.version : config.get('save-prefix') + p.version;
deps[d] = undefined + p.version;
return next();
});
});
@@ -61,11 +60,7 @@ function readDeps (test) {
var name = pkg.name || defaults.id || basename;
exports.name = yes ? name : prompt('name', name);

var version = pkg.version ||
defaults.version ||
config.get('init.version') ||
config.get('init-version') ||
'1.0.0';
var version = pkg.version || defaults.version || '1.0.0';
exports.version = yes ? version : prompt('version', version);

if (!pkg.description) {
@@ -139,22 +134,8 @@ if (!pkg.engines) {
}

if (!pkg.author) {
exports.author = (config.get('init.author.name') ||
config.get('init-author-name')) ?
{
'name': config.get('init.author.name') ||
config.get('init-author-name'),
'email': config.get('init.author.email') ||
config.get('init-author-email'),
'url': config.get('init.author.url') ||
config.get('init-author-url')
}
: prompt('author');
exports.author = prompt('author');
}
var license = pkg.license ||
defaults.license ||
config.get('init.license') ||
config.get('init-license') ||
'ISC';

const license = pkg.license || defaults.license || 'ISC';
exports.license = yes ? license : prompt('license', license);

0 comments on commit 2d9f101

Please sign in to comment.