Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

feature/catch failed write of hidden lockfile #53

Closed
wants to merge 2 commits into from

Conversation

mikemimik
Copy link

What / Why

When you try and run reify() in a folder with a package.json which doesn't have any dependencies we get an ENOENT error because we're attempting to save the .package-lock.json file into the node_modules/ folder which wasn't created because there are no deps.

References

@mikemimik mikemimik added the semver:patch semver patch level for changes label Mar 19, 2020
@mikemimik mikemimik added this to the OSS - Sprint 6 milestone Mar 19, 2020
@mikemimik mikemimik self-assigned this Mar 19, 2020
@mikemimik mikemimik requested a review from a team March 19, 2020 05:51
@mikemimik
Copy link
Author

Failing tests are because of one line missing from coverage. This is the throw err in case it's not an ENOENT error. Which I'm not sure if this is needed.

------------------------|----------|----------|----------|----------|-------------------|
File                    |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
------------------------|----------|----------|----------|----------|-------------------|
All files               |    99.96 |    99.93 |      100 |    99.95 |                   |
 lib                    |    99.92 |     99.9 |      100 |    99.92 |                   |
  add-rm-pkg-deps.js    |      100 |      100 |      100 |      100 |                   |
  calc-dep-flags.js     |      100 |      100 |      100 |      100 |                   |
  consistent-resolve.js |      100 |      100 |      100 |      100 |                   |
  dep-valid.js          |      100 |      100 |      100 |      100 |                   |
  diff.js               |      100 |      100 |      100 |      100 |                   |
  edge.js               |      100 |      100 |      100 |      100 |                   |
  gather-dep-set.js     |      100 |      100 |      100 |      100 |                   |
  index.js              |      100 |      100 |      100 |      100 |                   |
  inventory.js          |      100 |      100 |      100 |      100 |                   |
  link.js               |      100 |      100 |      100 |      100 |                   |
  name-from-folder.js   |      100 |      100 |      100 |      100 |                   |
  node.js               |      100 |      100 |      100 |      100 |                   |
  optional-set.js       |      100 |      100 |      100 |      100 |                   |
  retire-path.js        |      100 |      100 |      100 |      100 |                   |
  shrinkwrap.js         |    99.66 |    99.63 |      100 |    99.65 |               671 |
  spec-from-lock.js     |      100 |      100 |      100 |      100 |                   |
  tracker.js            |      100 |      100 |      100 |      100 |                   |
  update-dep-spec.js    |      100 |      100 |      100 |      100 |                   |
  version-from-tgz.js   |      100 |      100 |      100 |      100 |                   |
  yarn-lock.js          |      100 |      100 |      100 |      100 |                   |
 lib/arborist           |      100 |      100 |      100 |      100 |                   |
  build-ideal-tree.js   |      100 |      100 |      100 |      100 |                   |
  index.js              |      100 |      100 |      100 |      100 |                   |
  load-actual.js        |      100 |      100 |      100 |      100 |                   |
  load-virtual.js       |      100 |      100 |      100 |      100 |                   |
  reify.js              |      100 |      100 |      100 |      100 |                   |
------------------------|----------|----------|----------|----------|-------------------|
@mikemimik mikemimik force-pushed the mikemimik/feature/catch-failed-write branch from 2457d88 to d1ec7f6 Compare March 19, 2020 15:47
@isaacs isaacs closed this in 9b74dfd Mar 20, 2020
isaacs pushed a commit that referenced this pull request Mar 20, 2020
If there are no dependencies, then the node_modules folder may be
missing, meaning that the hidden lockfile will fail to write.

Also, a hidden lockfile is a best-effort performance boost anyway, so we
should just ignore failures to write it.

PR-URL: #53
Credit: @mikemimik
Close: #53
Reviewed-by: @isaacs

EDIT(@isaacs): Updated to ignore errors and remove the file, rather than
creating the node_modules folder on any ENOENT from the write.
@ruyadorno ruyadorno deleted the mikemimik/feature/catch-failed-write branch May 25, 2020 14:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
semver:patch semver patch level for changes
1 participant