Actualizacion de seguridad
This commit is contained in:
89
node_modules/nodemon/lib/config/load.js
generated
vendored
89
node_modules/nodemon/lib/config/load.js
generated
vendored
@@ -16,7 +16,11 @@ var existsSync = fs.existsSync || path.existsSync;
|
||||
function findAppScript() {
|
||||
// nodemon has been run alone, so try to read the package file
|
||||
// or try to read the index.js file
|
||||
if (existsSync('./index.js')) {
|
||||
|
||||
var pkg =
|
||||
existsSync(path.join(process.cwd(), 'package.json')) &&
|
||||
require(path.join(process.cwd(), 'package.json'));
|
||||
if ((!pkg || pkg.main == undefined) && existsSync('./index.js')) {
|
||||
return 'index.js';
|
||||
}
|
||||
}
|
||||
@@ -62,7 +66,6 @@ function load(settings, options, config, callback) {
|
||||
options.ignore = defaults.ignore.concat(options.ignore);
|
||||
}
|
||||
|
||||
|
||||
// add in any missing defaults
|
||||
options = utils.merge(options, defaults);
|
||||
|
||||
@@ -74,11 +77,14 @@ function load(settings, options, config, callback) {
|
||||
}
|
||||
// if the script is found as a result of not being on the command
|
||||
// line, then we move any of the pre double-dash args in execArgs
|
||||
const n = options.scriptPosition === null ?
|
||||
options.args.length : options.scriptPosition;
|
||||
const n =
|
||||
options.scriptPosition === null
|
||||
? options.args.length
|
||||
: options.scriptPosition;
|
||||
|
||||
options.execArgs = (options.execArgs || [])
|
||||
.concat(options.args.splice(0, n));
|
||||
options.execArgs = (options.execArgs || []).concat(
|
||||
options.args.splice(0, n)
|
||||
);
|
||||
options.scriptPosition = null;
|
||||
|
||||
options.script = found;
|
||||
@@ -102,53 +108,11 @@ function load(settings, options, config, callback) {
|
||||
normaliseRules(options, callback);
|
||||
};
|
||||
|
||||
// if we didn't pick up a nodemon.json file & there's no cli ignores
|
||||
// then try loading an old style .nodemonignore file
|
||||
if (config.loaded.length === 0) {
|
||||
var legacy = loadLegacyIgnore.bind(null, options, config, ready);
|
||||
|
||||
// first try .nodemonignore, if that doesn't exist, try nodemon-ignore
|
||||
return legacy('.nodemonignore', function () {
|
||||
legacy('nodemon-ignore', function (options) {
|
||||
ready(options);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ready(options);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the old style nodemonignore files which is a list of patterns
|
||||
* in a file to ignore
|
||||
*
|
||||
* @param {Object} options nodemon user options
|
||||
* @param {Function} success
|
||||
* @param {String} filename ignore file (.nodemonignore or nodemon-ignore)
|
||||
* @param {Function} fail (optional) failure callback
|
||||
*/
|
||||
function loadLegacyIgnore(options, config, success, filename, fail) {
|
||||
var ignoreFile = path.join(process.cwd(), filename);
|
||||
|
||||
exists(ignoreFile, function (exists) {
|
||||
if (exists) {
|
||||
config.loaded.push(ignoreFile);
|
||||
return parse(ignoreFile, function (error, rules) {
|
||||
options.ignore = rules.raw;
|
||||
success(options);
|
||||
});
|
||||
}
|
||||
|
||||
if (fail) {
|
||||
fail(options);
|
||||
} else {
|
||||
success(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function normaliseRules(options, ready) {
|
||||
// convert ignore and watch options to rules/regexp
|
||||
rules.watch.add(options.watch);
|
||||
@@ -170,7 +134,7 @@ function normaliseRules(options, ready) {
|
||||
*/
|
||||
function loadFile(options, config, dir, ready) {
|
||||
if (!ready) {
|
||||
ready = function () { };
|
||||
ready = function () {};
|
||||
}
|
||||
|
||||
var callback = function (settings) {
|
||||
@@ -222,29 +186,32 @@ function loadFile(options, config, dir, ready) {
|
||||
|
||||
function loadPackageJSON(config, ready) {
|
||||
if (!ready) {
|
||||
ready = () => { };
|
||||
ready = () => {};
|
||||
}
|
||||
|
||||
const dir = process.cwd();
|
||||
const filename = path.join(dir, 'package.json');
|
||||
const packageLoadOptions = { configFile: filename };
|
||||
return loadFile(packageLoadOptions, config, dir, settings => {
|
||||
return loadFile(packageLoadOptions, config, dir, (settings) => {
|
||||
ready(settings.nodemonConfig || {});
|
||||
});
|
||||
}
|
||||
|
||||
function mutateExecOptions(options) {
|
||||
// work out the execOptions based on the final config we have
|
||||
options.execOptions = exec({
|
||||
script: options.script,
|
||||
exec: options.exec,
|
||||
args: options.args,
|
||||
scriptPosition: options.scriptPosition,
|
||||
nodeArgs: options.nodeArgs,
|
||||
execArgs: options.execArgs,
|
||||
ext: options.ext,
|
||||
env: options.env,
|
||||
}, options.execMap);
|
||||
options.execOptions = exec(
|
||||
{
|
||||
script: options.script,
|
||||
exec: options.exec,
|
||||
args: options.args,
|
||||
scriptPosition: options.scriptPosition,
|
||||
nodeArgs: options.nodeArgs,
|
||||
execArgs: options.execArgs,
|
||||
ext: options.ext,
|
||||
env: options.env,
|
||||
},
|
||||
options.execMap
|
||||
);
|
||||
|
||||
// clean up values that we don't need at the top level
|
||||
delete options.scriptPosition;
|
||||
|
||||
Reference in New Issue
Block a user