greenkeeperio / greenkeeper-lockfile

:lock: Your lockfile, up to date, all the time
https://greenkeeper.io
183 stars 73 forks source link

Fix crashing on git commit with no shrinkwrap updates in some cases #61

Closed sanderploegsma closed 6 years ago

sanderploegsma commented 7 years ago

This fixes a crash when a package.json has devDependencies that are not sorted alphabetically. npm install --save-dev sorts dependencies in the package.json, so when a lockfile is not changed by this script, it tries to commit nothing, which fails.

Note: this only affects versions of npm where devDependencies are not shrinkwrapped, such as npm 3.

Example case: the package.json has the following devDependencies:

{
  "devDependencies": {
    "typescript": "^2.4.2",
    "jest": "^21.0.1",
    "ts-jest": "^20.0.0"
  }
}

Let's say ts-jest gets updated to 21.0.0. Greenkeeper would create a new commit where just the version in the package.json is updated and the greenkeeper-lockfile-update script is triggered. This:

Now, the following happens:

janl commented 6 years ago

@boennemann could you have a look here. LGTM, but not too experienced with npm subtleties here. Mainly concerned with: does this break anything else?

janl commented 6 years ago

I’m closing this as we are getting ready to retire 1.x. Please re-open/rebase if this is still relevant in master