I have the following NPM script in my package.json:
{
"scripts": {
"lint": "tslint -c tslint.json src/**/**?(.test).ts?(x)"
}
}
And after I run npm run lint I get the following error:
> tslint -c tslint.json src/**/**?(.test).ts?(x)
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `tslint -c tslint.json src/**/**?(.test).ts?(x)'
It seems that I cannot use the character ( in my NPM script. How can I come around this? The script is a valid bash script.
I tried searching the issue but I couldn't find anything helpful.
Any help is appreciated.
Kind thanks!
Update:
It seems that running this command in my terminal (macOS) like so:
bash -c "tslint -c tslint.json src/**/**?(.test).ts?(x)"
I get the exact same error.
however if I run it like this:
bash -c "tslint -c tslint.json src/**/**?\(.test\).ts?\(x\)"
it seems to work in the terminal. But not in a NPM script.
Got it to work like so:
{
"scripts": {
"lint": "bash -c \"tslint -c tslint.json 'src/**/**?(.test).ts?(x)'\"",
}
}
or the more simpler version
{
"scripts": {
"lint": "tslint -c tslint.json 'src/**/**?(.test).ts?(x)'",
}
}
Credits go to @shellter.
tslint -c tslint.json src/**/**?\(.test\).ts?\(x\)bash -c "tslint -c tslint.json 'src/**/**?(.test).ts?(x)' "? (note the single-quote surrounding the problematic pattern (you may want/need to remove the space between'and"that I included for visibility) ). Good luck.bash -cprefix helped. Is it becausenpm runis using node runtime?