最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Stylelint failing silently as npm script - Stack Overflow

programmeradmin1浏览0评论

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 via npm 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
Add a ment  | 

2 Answers 2

Reset to default 10

The 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"
发布评论

评论列表(0)

  1. 暂无评论