MCPcopy
hub / github.com/remy/nodemon / nodemon

Function nodemon

lib/nodemon.js:24–251  ·  view source on GitHub ↗

* @param {import('..').NodemonSettings | string} settings * @returns {import('..').Nodemon}

(settings)

Source from the content-addressed store, hash-verified

22 * @returns {import('..').Nodemon}
23 */
24function nodemon(settings) {
25 bus.emit('boot');
26 nodemon.reset();
27
28 /** @type {import('..').NodemonSettings} */
29 let options
30
31 // allow the cli string as the argument to nodemon, and allow for
32 // `node nodemon -V app.js` or just `-V app.js`
33 if (typeof settings === 'string') {
34 settings = settings.trim();
35 if (settings.indexOf('node') !== 0) {
36 if (settings.indexOf('nodemon') !== 0) {
37 settings = 'nodemon ' + settings;
38 }
39 settings = 'node ' + settings;
40 }
41 options = cli.parse(settings);
42 } else options = settings;
43
44 // set the debug flag as early as possible to get all the detailed logging
45 if (options.verbose) {
46 utils.debug = true;
47 }
48
49 if (options.help) {
50 if (process.stdout.isTTY) {
51 process.stdout._handle.setBlocking(true); // nodejs/node#6456
52 }
53 console.log(help(options.help));
54 if (!config.required) {
55 process.exit(0);
56 }
57 }
58
59 if (options.version) {
60 version().then(function (v) {
61 console.log(v);
62 if (!config.required) {
63 process.exit(0);
64 }
65 });
66 return;
67 }
68
69 // nodemon tools like grunt-nodemon. This affects where
70 // the script is being run from, and will affect where
71 // nodemon looks for the nodemon.json files
72 if (options.cwd) {
73 // this is protection to make sure we haven't dont the chdir already...
74 // say like in cli/parse.js (which is where we do this once already!)
75 if (process.cwd() !== path.resolve(config.system.cwd, options.cwd)) {
76 process.chdir(options.cwd);
77 }
78 }
79
80 config.load(options, function (config) {
81 if (!config.options.dump && !config.options.execOptions.script &&

Callers 11

require.test.jsFile · 0.85
runFunction · 0.85
count.test.jsFile · 0.85
run.test.jsFile · 0.85
complete.test.jsFile · 0.85
scripts.test.jsFile · 0.85
env.test.jsFile · 0.85
load.test.jsFile · 0.85
nodemon.jsFile · 0.85

Calls 2

helpFunction · 0.85
versionFunction · 0.85

Tested by 1

runFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…