- Searches your
package.json
for github dependencies, indicated by thegithub:
prefix - Fetches their latest commit ID using
git ls-remote
- Appends the new commit ID to the dependency, forcing npm to install the latest version
{
...
"dependencies": {
"react": "github:facebook/react",
"lodash": "github:lodash/lodash"
}
}
$ npm-use-latest
Fetching latest commit ID for react
Fetching latest commit ID for lodash
Successfully updated package.json
{
...
"dependencies": {
"react": "github:facebook/react#4045747af6bb83a73ef6057abd07017ee056a5f7",
"lodash": "github:lodash/lodash#2c5f026d3c59a38c429246513437681569b523b8"
}
}
npm i -g cmmartin/npm-use-latest
I'll publish this to npm eventually and save you those extra 9 characters
Navigate to your project root and run it!
cd path/to/my/project/root
npm-use-latest
- A recent enough version of npm that supports github dependencies
- A recent enough version of node.js that supports ecma 6 syntax (const, arrow functions, etc)
- git