Reputation: 16122
I'm trying to pull my files from git before running my app, I'm using git pull && node ./bin/www
and the application hangs.I'm new to Nodejs
Is there another way of doing this?
{
"name": "matcha",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "git pull && node ./bin/www"
},
"dependencies": {
"base-64": "^0.1.0",
"bcryptjs": "^2.3.0",
"body-parser": "~1.15.2",
"cookie-parser": "~1.4.3",
"crypto": "0.0.3",
"debug": "~2.2.0",
"ejs": "~2.5.2",
"express": "~4.14.0",
"express-session": "^1.14.2",
"fs": "0.0.1-security",
"morgan": "~1.7.0",
"multer": "^1.2.0",
"mysql": "^2.12.0",
"nodemailer": "^2.6.4",
"path": "^0.12.7",
"serve-favicon": "~2.3.0"
},
"repository": {
"type": "git",
"url": "https://github.com/julekgwa/Matcha.git"
}
}
Upvotes: 1
Views: 4264
Reputation: 992
Based on @galkin answer, but with checking if the package.json or package-lock.json changed before running npm install. Also, only install dependencies from package-lock.json, and only production dependencies.
"scripts": {
"prestart": "if git pull | grep 'package'; then npm ci --production; fi",
"start": "node src/index.js"
},
Upvotes: 0
Reputation: 5519
You can use prestart
.
When you are updating your dependencies, you need run npm install
. So scripts example is:
"scripts": {
"prestart": "git pull && npm install",
"start": "node ./bin/www"
}
Upvotes: 3