nlf / shrinkydink

an npm-shrinkwrap.json sanitizer
3 stars 3 forks source link

Also look for ../npm-shrinkwrap.json for easier postshrinkwrap integration #2

Open analog-nico opened 8 years ago

analog-nico commented 8 years ago

Since npm@3.10.0 a "postshrinkwrap" lifecycle hook is supported. Integrating shrinkydink becomes very easy with that:

  1. Run npm install shrinkydink --save-dev
  2. Add shrinkydink to the lifecycle hook:
{
  "scripts": {
    "postshrinkwrap": "shrinkydink ../npm-shrinkwrap.json"
  }
}

When executing npm shrinkwrap shrinkydink is executed in ./node_modules/ folder (= process.cwd()).

You could check process.cwd() if the last folder is "node_modules" and in that case search for ../npm-shrinkwrap.json instead of npm-shrinkwrap.json.

Then the "postshrinkwrap" integration would become even easier:

{
  "scripts": {
    "postshrinkwrap": "shrinkydink"
  }
}