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
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
postinstalllifecycle hook to set up the dev environment (generate code, deploy changes, etc.). So avoiding unnecessary installs is important to me.Nice one. I am looking for solutions on how to improve:
Your opinions, suggestions would be highly appreciated.
Shouldn't you run
npm ciinstead ofnpm install?Won't
npm installtry to update your package.json?If the semver versions in
package.jsonandpackage-lock.jsonfit with each other,npm installshould behave identically tonpm ci.For more information check this comment by the creator of
npm ci: dev.to/zkat/comment/epbjThis 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! :-)
Hi 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.
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 installinstead ofnpm installinside the hook.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.
Say goodbay to ‘npm install’, no need ‘npm install’, throw away ‘npm install’.