NUEVA BUSQUEDA DE DATOS SRI

This commit is contained in:
2023-04-11 10:50:28 -05:00
parent d9d7eb83cb
commit 6b4b3e263c
612 changed files with 11604 additions and 36692 deletions

View File

@@ -1,7 +1,7 @@
var ignoreRoot = require('ignore-by-default').directories();
// default options for config.options
module.exports = {
const defaults = {
restartable: 'rs',
colours: true,
execMap: {
@@ -12,7 +12,7 @@ module.exports = {
// compatible with linux, mac and windows, or make the default.js
// dynamically append the `.cmd` for node based utilities
},
ignoreRoot: ignoreRoot.map(_ => `**/${_}/**`),
ignoreRoot: ignoreRoot.map((_) => `**/${_}/**`),
watch: ['*.*'],
stdin: true,
runOnChangeOnly: false,
@@ -22,7 +22,11 @@ module.exports = {
// but also includes stderr. If this is false, data is still dispatched via
// nodemon.on('stdout/stderr')
stdout: true,
watchOptions: {
},
watchOptions: {},
};
if ((process.env.NODE_OPTIONS || '').includes('--loader')) {
delete defaults.execMap.ts;
}
module.exports = defaults;

View File

@@ -17,7 +17,7 @@ function reset() {
rules.reset();
config.dirs = [];
config.options = { ignore: [], watch: [] };
config.options = { ignore: [], watch: [], monitor: [] };
config.lastStarted = 0;
config.loaded = [];
}

View File

@@ -74,7 +74,9 @@ 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 || options.args.length;
const n = options.scriptPosition === null ?
options.args.length : options.scriptPosition;
options.execArgs = (options.execArgs || [])
.concat(options.args.splice(0, n));
options.scriptPosition = null;

View File

@@ -157,6 +157,12 @@ function match(files, monitor, ext) {
if (s.indexOf('!' + cwd) === 0) {
return s;
}
// if it starts with a period, then let's get the relative path
if (s.indexOf('!.') === 0) {
return '!' + path.resolve(cwd, s.substring(1));
}
return '!**' + (prefix !== path.sep ? path.sep : '') + s.slice(1);
}
@@ -195,12 +201,13 @@ function match(files, monitor, ext) {
for (var i = 0; i < rules.length; i++) {
if (rules[i].slice(0, 1) === '!') {
if (!minimatch(file, rules[i], minimatchOpts)) {
debug('ignored', file, 'rule:', rules[i]);
ignored++;
matched = true;
break;
}
} else {
debug('match', file, minimatch(file, rules[i], minimatchOpts));
debug('matched', file, 'rule:', rules[i]);
if (minimatch(file, rules[i], minimatchOpts)) {
watched++;

View File

@@ -5,6 +5,7 @@ var bus = utils.bus;
var childProcess = require('child_process');
var spawn = childProcess.spawn;
var exec = childProcess.exec;
var execSync = childProcess.execSync;
var fork = childProcess.fork;
var watch = require('./watch').watch;
var config = require('../config');
@@ -15,19 +16,35 @@ var restart = null;
var psTree = require('pstree.remy');
var path = require('path');
var signals = require('./signals');
const osRelease = parseInt(require('os').release().split('.')[0], 10);
function run(options) {
var cmd = config.command.raw;
// moved up
// we need restart function below in the global scope for run.kill
/*jshint validthis:true*/
restart = run.bind(this, options);
run.restart = restart;
// binding options with instance of run
// so that we can use it in run.kill
run.options = options;
var runCmd = !options.runOnChangeOnly || config.lastStarted !== 0;
if (runCmd) {
utils.log.status('starting `' + config.command.string + '`');
} else {
// should just watch file if command is not to be run
// had another alternate approach
// to stop process being forked/spawned in the below code
// but this approach does early exit and makes code cleaner
debug('start watch on: %s', config.options.watch);
if (config.options.watch !== false) {
watch();
return;
}
}
/*jshint validthis:true*/
restart = run.bind(this, options);
run.restart = restart;
config.lastStarted = Date.now();
var stdio = ['pipe', 'pipe', 'pipe'];
@@ -47,10 +64,10 @@ function run(options) {
const spawnOptions = {
env: Object.assign({}, process.env, options.execOptions.env, {
PATH: binPath + ':' + process.env.PATH,
PATH: binPath + path.delimiter + process.env.PATH,
}),
stdio: stdio,
}
};
var executable = cmd.executable;
@@ -59,17 +76,21 @@ function run(options) {
// but *only* apply to the first command, and none of the arguments.
// ref #1251 and #1236
if (executable.indexOf('/') !== -1) {
executable = executable.split(' ').map((e, i) => {
if (i === 0) {
return path.normalize(e);
}
return e;
}).join(' ');
executable = executable
.split(' ')
.map((e, i) => {
if (i === 0) {
return path.normalize(e);
}
return e;
})
.join(' ');
}
// taken from npm's cli: https://git.io/vNFD4
sh = process.env.comspec || 'cmd';
shFlag = '/d /s /c';
spawnOptions.windowsVerbatimArguments = true;
spawnOptions.windowsHide = true;
}
var args = runCmd ? utils.stringify(executable, cmd.args) : ':';
@@ -94,19 +115,25 @@ function run(options) {
!(firstArg.indexOf('-') === 0) && // don't fork if there's a node exec arg
firstArg !== 'inspect' && // don't fork it's `inspect` debugger
executable === 'node' && // only fork if node
utils.version.major > 4 // only fork if node version > 4
utils.version.major > 4; // only fork if node version > 4
if (shouldFork) {
// this assumes the first argument is the script and slices it out, since
// we're forking
var forkArgs = cmd.args.slice(1);
var env = utils.merge(options.execOptions.env, process.env);
stdio.push('ipc');
child = fork(options.execOptions.script, forkArgs, {
const forkOptions = {
env: env,
stdio: stdio,
silent: !hasStdio,
});
};
if (utils.isWindows) {
forkOptions.windowsHide = true;
}
child = fork(options.execOptions.script, forkArgs, forkOptions);
utils.log.detail('forking');
debug('fork', sh, shFlag, args)
debug('fork', sh, shFlag, args);
} else {
utils.log.detail('spawning');
child = spawn.apply(null, spawnArgs);
@@ -162,8 +189,9 @@ function run(options) {
}
if (code === 127) {
utils.log.error('failed to start process, "' + cmd.executable +
'" exec not found');
utils.log.error(
'failed to start process, "' + cmd.executable + '" exec not found'
);
bus.emit('error', code);
process.exit();
}
@@ -208,7 +236,8 @@ function run(options) {
return restart();
}
if (code === 0) { // clean exit - wait until file change to restart
if (code === 0) {
// clean exit - wait until file change to restart
if (runCmd) {
utils.log.status('clean exit - waiting for changes before restart');
}
@@ -222,8 +251,9 @@ function run(options) {
process.exit(1);
}
} else {
utils.log.fail('app crashed - waiting for file changes before' +
' starting...');
utils.log.fail(
'app crashed - waiting for file changes before' + ' starting...'
);
child = null;
}
}
@@ -235,53 +265,9 @@ function run(options) {
}
});
run.kill = function (noRestart, callback) {
// I hate code like this :( - Remy (author of said code)
if (typeof noRestart === 'function') {
callback = noRestart;
noRestart = false;
}
if (!callback) {
callback = noop;
}
if (child !== null) {
// if the stdin piping is on, we need to unpipe, but also close stdin on
// the child, otherwise linux can throw EPIPE or ECONNRESET errors.
if (options.stdin) {
process.stdin.unpipe(child.stdin);
}
// For the on('exit', ...) handler above the following looks like a
// crash, so we set the killedAfterChange flag if a restart is planned
if (!noRestart) {
killedAfterChange = true;
}
/* Now kill the entire subtree of processes belonging to nodemon */
var oldPid = child.pid;
if (child) {
kill(child, config.signal, function () {
// this seems to fix the 0.11.x issue with the "rs" restart command,
// though I'm unsure why. it seems like more data is streamed in to
// stdin after we close.
if (child && options.stdin && child.stdin && oldPid === child.pid) {
child.stdin.end();
}
callback();
});
}
} else if (!noRestart) {
// if there's no child, then we need to manually start the process
// this is because as there was no child, the child.on('exit') event
// handler doesn't exist which would normally trigger the restart.
bus.once('start', callback);
restart();
} else {
callback();
}
};
// moved the run.kill outside to handle both the cases
// intial start
// no start
// connect stdin to the child process (options.stdin is on by default)
if (options.stdin) {
@@ -292,21 +278,25 @@ function run(options) {
// swallow the stdin error if it happens
// ref: https://github.com/remy/nodemon/issues/1195
if (hasStdio) {
child.stdin.on('error', () => { });
child.stdin.on('error', () => {});
process.stdin.pipe(child.stdin);
} else {
if (child.stdout) {
child.stdout.pipe(process.stdout);
} else {
utils.log.error('running an unsupported version of node ' +
process.version);
utils.log.error('nodemon may not work as expected - ' +
'please consider upgrading to LTS');
utils.log.error(
'running an unsupported version of node ' + process.version
);
utils.log.error(
'nodemon may not work as expected - ' +
'please consider upgrading to LTS'
);
}
}
bus.once('exit', function () {
if (child && process.stdin.unpipe) { // node > 0.8
if (child && process.stdin.unpipe) {
// node > 0.8
process.stdin.unpipe(child.stdin);
}
});
@@ -325,26 +315,80 @@ function waitForSubProcesses(pid, callback) {
return callback();
}
utils.log.status(`still waiting for ${pids.length} sub-process${
pids.length > 2 ? 'es' : ''} to finish...`);
utils.log.status(
`still waiting for ${pids.length} sub-process${
pids.length > 2 ? 'es' : ''
} to finish...`
);
setTimeout(() => waitForSubProcesses(pid, callback), 1000);
});
}
function kill(child, signal, callback) {
if (!callback) {
callback = function () { };
callback = noop;
}
if (utils.isWindows) {
// When using CoffeeScript under Windows, child's process is not node.exe
// Instead coffee.cmd is launched, which launches cmd.exe, which starts
// node.exe as a child process child.kill() would only kill cmd.exe, not
// node.exe
// Therefore we use the Windows taskkill utility to kill the process and all
// its children (/T for tree).
// Force kill (/F) the whole child tree (/T) by PID (/PID 123)
exec('taskkill /pid ' + child.pid + ' /T /F');
const taskKill = () => {
try {
exec('taskkill /pid ' + child.pid + ' /T /F');
} catch (e) {
utils.log.error('Could not shutdown sub process cleanly');
}
};
// We are handling a 'SIGKILL' , 'SIGUSR2' and 'SIGUSR1' POSIX signal under Windows the
// same way it is handled on a UNIX system: We are performing
// a hard shutdown without waiting for the process to clean-up.
if (signal === 'SIGKILL' || osRelease < 10 || signal === 'SIGUSR2' || signal==="SIGUSR1" ) {
debug('terminating process group by force: %s', child.pid);
// We are using the taskkill utility to terminate the whole
// process group ('/t') of the child ('/pid') by force ('/f').
// We need to end all sub processes, because the 'child'
// process in this context is actually a cmd.exe wrapper.
taskKill();
callback();
return;
}
try {
// We are using the Windows Management Instrumentation Command-line
// (wmic.exe) to resolve the sub-child process identifier, because the
// 'child' process in this context is actually a cmd.exe wrapper.
// We want to send the termination signal directly to the node process.
// The '2> nul' silences the no process found error message.
const resultBuffer = execSync(
`wmic process where (ParentProcessId=${child.pid}) get ProcessId 2> nul`
);
const result = resultBuffer.toString().match(/^[0-9]+/m);
// If there is no sub-child process we fall back to the child process.
const processId = Array.isArray(result) ? result[0] : child.pid;
debug('sending kill signal SIGINT to process: %s', processId);
// We are using the standalone 'windows-kill' executable to send the
// standard POSIX signal 'SIGINT' to the node process. This fixes #1720.
const windowsKill = path.normalize(
`${__dirname}/../../bin/windows-kill.exe`
);
// We have to detach the 'windows-kill' execution completely from this
// process group to avoid terminating the nodemon process itself.
// See: https://github.com/alirdn/windows-kill#how-it-works--limitations
//
// Therefore we are using 'start' to create a new cmd.exe context.
// The '/min' option hides the new terminal window and the '/wait'
// option lets the process wait for the command to finish.
execSync(
`start "windows-kill" /min /wait "${windowsKill}" -SIGINT ${processId}`
);
} catch (e) {
taskKill();
}
callback();
} else {
// we use psTree to kill the full subtree of nodemon, because when
@@ -367,24 +411,64 @@ function kill(child, signal, callback) {
child.kill(signal);
pids.sort().forEach(pid => exec(`kill -${sig} ${pid}`, noop));
pids.sort().forEach((pid) => exec(`kill -${sig} ${pid}`, noop));
waitForSubProcesses(child.pid, () => {
// finally kill the main user process
exec(`kill -${sig} ${child.pid}`, callback);
});
});
}
}
// stubbed out for now, filled in during run
run.kill = function (flag, callback) {
if (callback) {
run.kill = function (noRestart, callback) {
// I hate code like this :( - Remy (author of said code)
if (typeof noRestart === 'function') {
callback = noRestart;
noRestart = false;
}
if (!callback) {
callback = noop;
}
if (child !== null) {
// if the stdin piping is on, we need to unpipe, but also close stdin on
// the child, otherwise linux can throw EPIPE or ECONNRESET errors.
if (run.options.stdin) {
process.stdin.unpipe(child.stdin);
}
// For the on('exit', ...) handler above the following looks like a
// crash, so we set the killedAfterChange flag if a restart is planned
if (!noRestart) {
killedAfterChange = true;
}
/* Now kill the entire subtree of processes belonging to nodemon */
var oldPid = child.pid;
if (child) {
kill(child, config.signal, function () {
// this seems to fix the 0.11.x issue with the "rs" restart command,
// though I'm unsure why. it seems like more data is streamed in to
// stdin after we close.
if (child && run.options.stdin && child.stdin && oldPid === child.pid) {
child.stdin.end();
}
callback();
});
}
} else if (!noRestart) {
// if there's no child, then we need to manually start the process
// this is because as there was no child, the child.on('exit') event
// handler doesn't exist which would normally trigger the restart.
bus.once('start', callback);
run.restart();
} else {
callback();
}
};
run.restart = noop;
bus.on('quit', function onQuit(code) {
@@ -440,7 +524,9 @@ bus.on('restart', function () {
// remove the child file on exit
process.on('exit', function () {
utils.log.detail('exiting');
if (child) { child.kill(); }
if (child) {
child.kill();
}
});
// because windows borks when listening for the SIG* events
@@ -450,10 +536,11 @@ if (!utils.isWindows) {
process.once('SIGINT', () => bus.emit('quit', 130));
process.once('SIGTERM', () => {
bus.emit('quit', 143);
if (child) { child.kill('SIGTERM'); }
if (child) {
child.kill('SIGTERM');
}
});
})
});
}
module.exports = run;

View File

@@ -177,7 +177,7 @@ function filterAndRestart(files) {
// if there's no matches, then test to see if the changed file is the
// running script, if so, let's allow a restart
if (config.options.execOptions.script) {
if (config.options.execOptions && config.options.execOptions.script) {
const script = path.resolve(config.options.execOptions.script);
if (matched.result.length === 0 && script) {
const length = script.length;

View File

@@ -39,7 +39,9 @@ function nodemon(settings) {
}
if (settings.help) {
process.stdout._handle.setBlocking(true); // nodejs/node#6456
if (process.stdout.isTTY) {
process.stdout._handle.setBlocking(true); // nodejs/node#6456
}
console.log(help(settings.help));
if (!config.required) {
process.exit(0);
@@ -180,7 +182,7 @@ function nodemon(settings) {
}).filter(Boolean).join(' ');
if (ignoring) utils.log.detail('ignoring: ' + ignoring);
utils.log.info('watching dir(s): ' + config.options.monitor.map(function (rule) {
utils.log.info('watching path(s): ' + config.options.monitor.map(function (rule) {
if (rule.slice(0, 1) !== '!') {
try {
rule = path.relative(process.cwd(), rule);

43
node_modules/nodemon/lib/spawn.js generated vendored
View File

@@ -1,3 +1,4 @@
const path = require('path');
const utils = require('./utils');
const merge = utils.merge;
const bus = utils.bus;
@@ -10,26 +11,44 @@ module.exports = function spawnCommand(command, config, eventArgs) {
stdio = ['pipe', process.stdout, process.stderr];
}
const env = merge(process.env, { FILENAME: eventArgs[0] });
var sh = 'sh';
var shFlag = '-c';
if (utils.isWindows) {
sh = 'cmd';
shFlag = '/c';
}
var spawnOptions = {
env: merge(config.options.execOptions.env, env),
stdio: stdio,
};
if (!Array.isArray(command)) {
command = [command];
}
const args = command.join(' ');
if (utils.isWindows) {
// if the exec includes a forward slash, reverse it for windows compat
// but *only* apply to the first command, and none of the arguments.
// ref #1251 and #1236
command = command.map(executable => {
if (executable.indexOf('/') === -1) {
return executable;
}
const env = merge(process.env, { FILENAME: eventArgs[0] });
const child = spawn(sh, [shFlag, args], {
env: merge(config.options.execOptions.env, env),
stdio: stdio,
});
return executable.split(' ').map((e, i) => {
if (i === 0) {
return path.normalize(e);
}
return e;
}).join(' ');
});
// taken from npm's cli: https://git.io/vNFD4
sh = process.env.comspec || 'cmd';
shFlag = '/d /s /c';
spawnOptions.windowsVerbatimArguments = true;
spawnOptions.windowsHide = true;
}
const args = command.join(' ');
const child = spawn(sh, [shFlag, args], spawnOptions);
if (config.required) {
var emit = {