petruisfan / node-supervisor

Other
3.76k stars 260 forks source link

Arguments Incorrectly Parsed #228

Open cawoodm opened 1 year ago

cawoodm commented 1 year ago

If I run supervisor script.js arg1 I expect it to run node script.js arg1 however it seems to be running node arg1.

$supervisor -- .\tests\script.js arg1

Running node-supervisor with
  program 'arg1'
  --watch '.'
  --extensions 'node,js'
  --exec 'node'

Starting child process with 'node arg1'
Watching directory 'C:\projects\order' for changes.
Press rs for restarting the process.
node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module 'C:\projects\order\arg1'
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.12.1
Program node arg1 exited with code 1

Version: latest: 0.12.0

Possibly related to #191

cawoodm commented 1 year ago

Just to add - I am running this from Powershell v7 on Windows 10.

If I run it from the command prompt cmd.exe it works fine.

cawoodm commented 1 year ago

Correction - it works under cmd.exe UNLESS we pass arguments to supervisor

Working

$supervisor -- .\tests\script.js arg1

Running node-supervisor with
  program '.\tests\script.js arg1'
  --watch '.'
  --extensions 'node,js'
  --exec 'node'

Starting child process with 'node .\tests\script.js arg1'
Watching directory 'C:\projects\order' for changes.
Press rs for restarting the process.

Not Working

$supervisor -w tests -n -- .\tests\script.js arg1

Running node-supervisor with
  program 'arg1'
  --watch 'tests'
  --extensions 'node,js'
  --exec 'node'

Starting child process with 'node arg1'
Watching directory 'C:\projects\order\tests' for changes.
Press rs for restarting the process.
node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module 'C:\projects\order\arg1'
cawoodm commented 1 year ago

Weirdly, adding -V (or even -v) causes it to work - though it would appear -v (or whatever) is ignored:

C:\projects\order>supervisor -w tests -n -V -- .\tests\script.js arg1