promise-spawn icon indicating copy to clipboard operation
promise-spawn copied to clipboard

Positional arguments in `npm run-script`

Open piranna opened this issue 1 year ago • 0 comments

https://github.com/npm/promise-spawn/blob/8e991758db8ccd18e2adba42b6689007a3cfb071/lib/index.js#L116-L123

We are concatenating the user provided arguments to the command_string, but POSIX shell -c flag allow extra arguments, one to set the $0 (process name) of the executed script from the command_string, and next ones to define the other positional arguments ($1, $2, $3...). It seems like a dumb change, but since we are just concatenating the strings to the real_args variable, $@ and $* are shown as empty, so for example it's not possible to use variables expansion with them like eslint ${@:-.} on package.json scripts to set current directory as default value if files argument are not provided when executing npm run.

piranna avatar Jul 10 '23 02:07 piranna