-
Notifications
You must be signed in to change notification settings - Fork 3k
npm run removes quotes from given parameters #7743
Comments
Thanks for reporting this. This is known behavior, though I don't know if there's another issue for it already. It happens because I'm not sure there's a general way to solve the problem, though, as the quotes are gone by the time EDIT: to add |
Well, the workaround is to not use the feature if I have command parameters that need to be quoted :) I had a look and as a quick and dirty hack I replaced this line with this: joinedArgs += " '" + arg + "'" It fixes this specific issue, but I'm not sure whether this works as a valid solution in general or whether it will introduce other issues. Thoughts? |
Just off the top of my head, It will cause an error in the shell if the arg before shell expansion is So that's probably not a viable long-term fix. The workaround you have found is to denormalize the commands, repeating
That way the arguments don't get passed through |
Oddly enough, this results in no quotes being removed: {
"scripts": {
"test": "mochify",
"cover": "mochify --plugin [ mochify-istanbul --report cobertura --exclude \"'**/*.mustache'\" ]"
}
} $ npm run cover
> @ cover
> npm run test -- --plugin [ mochify-istanbul --report cobertura --exclude "'**/*.mustache'" ]
> @ test
> mochify --plugin [ mochify-istanbul --report cobertura --exclude "'**/*.mustache'" ] |
@kenany You're just doing the escaping for npm ;-) @smikes Good point. If an argument contains |
I'm using npm as a build tool and ran into the following issue with
npm run
and quoted parameters.This is the interesting part of the "scripts" section in my package.json:
Running
npm run cover
prints this:You can see that
**/*.mustache
is quoted on the first line, but the quotes are removed on the second line. This causes the script to fail because I have to pass the glob expression as a plain string.If I change the cover script to this:
... calling
npm run cover
works fine and npm prints the quotes as expected:Thanks for looking into it!
The text was updated successfully, but these errors were encountered: