From 010266adb5d318e973a0a67d2eabd628bd759c21 Mon Sep 17 00:00:00 2001 From: Larissa Rosalene <10000537+lerarosalene@users.noreply.github.com> Date: Wed, 1 Feb 2023 05:05:30 +0300 Subject: [PATCH 1/3] Get rid of spawning shell windows if nodemon is started without console. If nodemon is started without it's own console (example: via pm2) on Windows, it spawns console windows for it's monitored processes. This should get rid of this behaviour. --- lib/spawn.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/spawn.js b/lib/spawn.js index 9aa4f80e..256734a0 100644 --- a/lib/spawn.js +++ b/lib/spawn.js @@ -44,6 +44,7 @@ module.exports = function spawnCommand(command, config, eventArgs) { sh = process.env.comspec || 'cmd'; shFlag = '/d /s /c'; spawnOptions.windowsVerbatimArguments = true; + spawnOptions.windowsHide = true; } const args = command.join(' '); From adaafa13e618165a82dc69105eaaa1d13b940e04 Mon Sep 17 00:00:00 2001 From: Larissa Rosalene <10000537+lerarosalene@users.noreply.github.com> Date: Wed, 1 Feb 2023 05:48:55 +0300 Subject: [PATCH 2/3] One more fix --- lib/monitor/run.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/monitor/run.js b/lib/monitor/run.js index 6e1fa24d..cbd905c0 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -90,6 +90,7 @@ function run(options) { sh = process.env.comspec || 'cmd'; shFlag = '/d /s /c'; spawnOptions.windowsVerbatimArguments = true; + spawnOptions.windowsHide = true; } var args = runCmd ? utils.stringify(executable, cmd.args) : ':'; @@ -122,11 +123,15 @@ function run(options) { 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); } else { From 146839711be58995f88723b29de3007de87d6c3a Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Thu, 16 Feb 2023 13:40:55 +0000 Subject: [PATCH 3/3] fix: remove ts mapping if loader present fixes #2083 --- lib/config/defaults.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/config/defaults.js b/lib/config/defaults.js index e2a448b4..c1795b99 100644 --- a/lib/config/defaults.js +++ b/lib/config/defaults.js @@ -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;