简体   繁体   中英

husky pre push hook before build

I'd like to implement a husky rule so as to make it run yarn build and make sure that what's going to be pushed won't break the app.

I've browsed the web, but still not sure if the following is the correct way to do it?

"husky": {
    "hooks": {
      "pre-commit": "cross-env lint-staged",
      "pre-push": "cross-env lint-staged yarn build"
    }
  },

The values assigned to pre-commit and pre-push should be the commands as if they were being run straight from the command line. In this case cross-env lint-staged yarn build will be run as one command before pushing. (Haven't used yarn so I'm not sure if that's right.)

Multiple commands can be chained together as follows:

"pre-commit": "command1 arg1 arg2 && command2"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM