UPDATE: I released a npm package for this script: git-pull-run. Please report any issues or suggestions to improve on GitHub.
Together with my t...
For further actions, you may consider blocking this person and/or reporting abuse
Nice one. I am looking for solutions on how to improve:
Your opinions, suggestions would be highly appreciated.
Can't we just run npm install on each pull
You mean always running install without checking for lock file changes? Of course that’s an option. I’m using npm’s
postinstall
lifecycle hook to set up the dev environment (generate code, deploy changes, etc.). So avoiding unnecessary installs is important to me.This is pretty cool, can it be a package one can just install?
I’m working on a npm package :)
I released a first version: npmjs.com/package/git-pull-run
I'd like to hear your thoughts! :-)
Shouldn't you run
npm ci
instead ofnpm install
?Won't
npm install
try to update your package.json?If the semver versions in
package.json
andpackage-lock.json
fit with each other,npm install
should behave identically tonpm ci
.For more information check this comment by the creator of
npm ci
: dev.to/zkat/comment/epbjHi there, nice article!
Do we need to setup this husky hook into package.json?
No, Husky in the latest version v7 doesn't work npm scripts anymore. Just follow these steps and it create a .husky folder in your repo. Then add a post-merge file with gist snippet above.
Say goodbay to ‘npm install’, no need ‘npm install’, throw away ‘npm install’.
Good point! Another way we are solving it at work is by using yarn pnp with zero installs. It's not bulletproof but surely helps a lot.
I’d like to use yarn pnp but it’s not widely supported yet. For example Typescript doesn’t support pnp at the moment (it’s being patched into TS by yarn during install). Also bundlers like webpack didn’t handle the lock file at root level correctly the last time I checked.
If we are using yarn then How to do same thing ?
That should be easy with changing the regex expression from package-lock.json to yarn.lock:
PACKAGE_LOCK_REGEX="(^packages\/.*\/yarn\.lock)|(^yarn\.lock)"
and runningyarn install
instead ofnpm install
inside the hook.