Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Positional arguments in npm run-script #69

Open
piranna opened this issue Jul 10, 2023 · 0 comments
Open

Positional arguments in npm run-script #69

piranna opened this issue Jul 10, 2023 · 0 comments

Comments

@piranna
Copy link

piranna commented Jul 10, 2023

promise-spawn/lib/index.js

Lines 116 to 123 in 8e99175

} else {
for (const arg of args) {
script += ` ${escape.sh(arg)}`
}
realArgs.push('-c', script)
}
return promiseSpawn(command, realArgs, options, extra)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant