简体   繁体   中英

“npm install” triggering grunt task?

Can npm install trigger a grunt task as part of installing a local package?

My web API is instrumented for automatic documentation generation, with a documentation site available directly from the web service. Currently, a separate step to execute the grunt task is required. I thought it may simplify deployment to have this step included during the npm install process.

If this can simply be done but you think I shouldn't, please let me know why.

Update

Indeed, a npm postinstall was the way to go. Also as mentioned, it seems with newer versions of grunt, grunt-cli is required. I installed grunt-cli as a dev dependency, then added the folowing to my package.json:

"scripts": {
    "postinstall": "./node_modules/.bin/grunt apidoc"
}

You can do it by using post install scripts. The thing is to run the grunt task you may need grunt CLI... If can go thorough with gulp... There won't be a problem..

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