如何运行"npm install"每次pm2-重新启动之前? [英] How to run "npm install" before every pm2-restart?
问题描述
我正在尝试通过PM2将一个hobby-node-app自动部署到我的Raspberry Pi 2.
I am trying to automatically deploy a hobby-node-app to my Raspberry Pi 2 via PM2.
PM2软件包"autopull"自动从我的Bitbucket-Repo(对于RBPi 2->主节点)的检出分支中提取最新提交,然后重新启动PM2.
The PM2 package "autopull" automatically pulls the latest commit from the checked out branch of my Bitbucket-Repo (in case of the RBPi 2 -> master) and restarts PM2.
但是,如果我在最新提交中的bower.json或package.json中添加了新的依赖项,则PM2不会安装这些依赖项.有没有一种方法可以让PM2在每次git pull之后自动运行"npm install&&bower install"?
However, if I add new dependencies in my bower.json or package.json in the latest commit, those would not be installed by PM2. Is there a way to have PM2 automatically run "npm install && bower install" after every git pull?
我也会对实现相同功能的其他设置感到满意.
I would also be satisfied with a different setup that would achieve the same thing.
推荐答案
尝试使用git hook!把它放到仓库的.git/hooks/post-merge文件中,如果没有的话就创建它.确保文件是可执行文件.
Try a git hook! Put this inside your repo's .git/hooks/post-merge file, create it if you don't have one. Make sure the file is executable.
#!/bin/sh
echo " GIT POST-MERGE NPM INSTALL"
exec npm install
echo " GIT POST-MERGE BOWER UPDATE"
exec bower update
这篇关于如何运行"npm install"每次pm2-重新启动之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!