Kinda baffled by this situation and would really appreciate if anyone can tell me what's going on!
I am working my way through this tutorial: https://www.smashingmagazine.com/2020/04/express-api-backend-project-postgresql/ And encountering weird behavior at the point where the guide has me set up ESLint/Prettier.
Following this guide, I have my scripts for linting/formatting thus:
"scripts": {
"lint": "./node_modules/.bin/eslint ./src",
"pretty": "prettier --write "**/*.{js,json}"",
"postpretty": "npm run lint --fix"
}
What I would assume would happen (and what the guide says should happen) is that if I run npm run pretty
, it should execute both pretty
and postpretty
.
But it doesn't. What actually happens is that it runs pretty
and then exits:
$ npm run pretty
> [email protected] pretty C:UsersmeDocuments\_ProgrammingGitHubproject-name
> prettier --write "**/*.{js,json}"
.eslintrc.json 47ms
nodemon.json 5ms
package-lock.json 304ms
package.json 39ms
srcapp.js 20ms
srcinwww.js 30ms
src
outesindex.js 10ms
No sign of the postpretty
command being fired.
The incredibly baffling thing about this is that if I change pretty
to a different word, everything works fine:
"scripts": {
"lint": "./node_modules/.bin/eslint ./src",
"blah": "prettier --write "**/*.{js,json}"",
"postblah": "npm run lint"
},
$ npm run blah
> [email protected] blah C:UsersmeDocuments\_ProgrammingGitHubproject-name
> prettier --write "**/*.{js,json}"
.eslintrc.json 40ms
nodemon.json 4ms
package-lock.json 306ms
package.json 31ms
srcapp.js 19ms
srcinwww.js 29ms
src
outesindex.js 9ms
> [email protected] postblah C:UsersmeDocuments\_ProgrammingGitHubproject-name
> npm run lint
> [email protected] lint C:UsersmeDocuments\_ProgrammingGitHubproject-name
> eslint ./src
# followed by expected ESLint errors
What could I possibly have done to disable the post hook only if the script is called pretty
? O.o Is there an npm setting hidden away somewhere that might have been enabled for that script name?
question from:
https://stackoverflow.com/questions/65651391/npm-post-hook-not-firing-for-one-command-only 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…