I'm setting up stylelint for a project, everything works as expected when run from the cli:
$ stylelint 'css/**/*.css' --fix
css/style.css
20:18 × Expected newline after ":" with a multi-line declaration declaration-colon-newline-after
...
...
However, when run as an npm script
no output appears (beyond logging the mand) and the errors seem to be ignored:
$ npm run stylelint
> project lint:css path/project
> stylelint 'css/**/*.css' --fix
package.json
"scripts": {
...
"stylelint": "stylelint 'css/**/*.css' --fix"
},
Any idea how to get the console output AND exit on errors when stylelint is run as an npm script?
I'm setting up stylelint for a project, everything works as expected when run from the cli:
$ stylelint 'css/**/*.css' --fix
css/style.css
20:18 × Expected newline after ":" with a multi-line declaration declaration-colon-newline-after
...
...
However, when run as an npm script
no output appears (beyond logging the mand) and the errors seem to be ignored:
$ npm run stylelint
> project lint:css path/project
> stylelint 'css/**/*.css' --fix
package.json
"scripts": {
...
"stylelint": "stylelint 'css/**/*.css' --fix"
},
Any idea how to get the console output AND exit on errors when stylelint is run as an npm script?
Share Improve this question edited Aug 22, 2018 at 19:44 Vinnie James asked Aug 22, 2018 at 19:35 Vinnie JamesVinnie James 6,0726 gold badges46 silver badges54 bronze badges 2-
It actually seems
> stylelint 'css/**/*.css' --fix
doesnt run at all vianpm
regardless of the fact it logs out to the console – Vinnie James Commented Aug 22, 2018 at 20:00 -
The issue is with the globstar pattern, as
"stylelint": "stylelint 'css/file.css' --fix"
runs as expected via npm – Vinnie James Commented Aug 22, 2018 at 20:07
2 Answers
Reset to default 10The issue turned out to be the quotes around the globstar pattern. Most other scripts allow you to wrap the globstar in single quotes '
, however stylelint seems to require escaped double quotes:
"stylelint": "stylelint \"src/**/*.css\" --fix"
Seems like appending ; exit 0
also does the trick:
"stylelint": "stylelint 'css/**/*.css' --fix; exit 0"