cacache 17.0.5 → 17.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,8 @@ const events = require('events')
4
4
 
5
5
  const contentPath = require('./path')
6
6
  const fs = require('fs/promises')
7
- const moveFile = require('../util/move-file')
8
- const Minipass = require('minipass')
7
+ const { moveFile } = require('@npmcli/fs')
8
+ const { Minipass } = require('minipass')
9
9
  const Pipeline = require('minipass-pipeline')
10
10
  const Flush = require('minipass-flush')
11
11
  const path = require('path')
@@ -161,8 +161,14 @@ async function moveToDestination (tmp, cache, sri, opts) {
161
161
  const destDir = path.dirname(destination)
162
162
 
163
163
  await fs.mkdir(destDir, { recursive: true })
164
- await moveFile(tmp.target, destination)
165
- tmp.moved = true
164
+ try {
165
+ await moveFile(tmp.target, destination, { overwrite: false })
166
+ tmp.moved = true
167
+ } catch (err) {
168
+ if (!err.message.startsWith('The destination file exists')) {
169
+ throw Object.assign(err, { code: 'EEXIST' })
170
+ }
171
+ }
166
172
  }
167
173
 
168
174
  function sizeError (expected, found) {
@@ -9,7 +9,7 @@ const {
9
9
  rm,
10
10
  writeFile,
11
11
  } = require('fs/promises')
12
- const Minipass = require('minipass')
12
+ const { Minipass } = require('minipass')
13
13
  const path = require('path')
14
14
  const ssri = require('ssri')
15
15
  const uniqueFilename = require('unique-filename')
package/lib/get.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const Collect = require('minipass-collect')
4
- const Minipass = require('minipass')
4
+ const { Minipass } = require('minipass')
5
5
  const Pipeline = require('minipass-pipeline')
6
6
 
7
7
  const index = require('./entry-index')
package/lib/util/glob.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const glob = require('glob')
3
+ const { glob } = require('glob')
4
4
 
5
5
  const globify = (pattern) => pattern.split('//').join('/')
6
6
  module.exports = (path, options) => glob(globify(path), options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacache",
3
- "version": "17.0.5",
3
+ "version": "17.0.7",
4
4
  "cache-version": {
5
5
  "content": "2",
6
6
  "index": "5"
@@ -47,21 +47,20 @@
47
47
  "dependencies": {
48
48
  "@npmcli/fs": "^3.1.0",
49
49
  "fs-minipass": "^3.0.0",
50
- "glob": "^9.3.1",
50
+ "glob": "^10.2.2",
51
51
  "lru-cache": "^7.7.1",
52
- "minipass": "^4.0.0",
52
+ "minipass": "^5.0.0",
53
53
  "minipass-collect": "^1.0.2",
54
54
  "minipass-flush": "^1.0.5",
55
55
  "minipass-pipeline": "^1.2.4",
56
56
  "p-map": "^4.0.0",
57
- "promise-inflight": "^1.0.1",
58
57
  "ssri": "^10.0.0",
59
58
  "tar": "^6.1.11",
60
59
  "unique-filename": "^3.0.0"
61
60
  },
62
61
  "devDependencies": {
63
62
  "@npmcli/eslint-config": "^4.0.0",
64
- "@npmcli/template-oss": "4.12.0",
63
+ "@npmcli/template-oss": "4.14.1",
65
64
  "tap": "^16.0.0"
66
65
  },
67
66
  "engines": {
@@ -70,7 +69,8 @@
70
69
  "templateOSS": {
71
70
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
72
71
  "windowsCI": false,
73
- "version": "4.12.0"
72
+ "version": "4.14.1",
73
+ "publish": "true"
74
74
  },
75
75
  "author": "GitHub Inc.",
76
76
  "tap": {
@@ -1,56 +0,0 @@
1
- 'use strict'
2
-
3
- const fs = require('fs/promises')
4
- const { moveFile: move } = require('@npmcli/fs')
5
- const pinflight = require('promise-inflight')
6
-
7
- module.exports = moveFile
8
-
9
- async function moveFile (src, dest) {
10
- const isWindows = process.platform === 'win32'
11
-
12
- // This isn't quite an fs.rename -- the assumption is that
13
- // if `dest` already exists, and we get certain errors while
14
- // trying to move it, we should just not bother.
15
- //
16
- // In the case of cache corruption, users will receive an
17
- // EINTEGRITY error elsewhere, and can remove the offending
18
- // content their own way.
19
- //
20
- // Note that, as the name suggests, this strictly only supports file moves.
21
- try {
22
- await fs.link(src, dest)
23
- } catch (err) {
24
- if (isWindows && err.code === 'EPERM') {
25
- // XXX This is a really weird way to handle this situation, as it
26
- // results in the src file being deleted even though the dest
27
- // might not exist. Since we pretty much always write files to
28
- // deterministic locations based on content hash, this is likely
29
- // ok (or at worst, just ends in a future cache miss). But it would
30
- // be worth investigating at some time in the future if this is
31
- // really what we want to do here.
32
- } else if (err.code === 'EEXIST' || err.code === 'EBUSY') {
33
- // file already exists, so whatever
34
- } else {
35
- throw err
36
- }
37
- }
38
- try {
39
- await Promise.all([
40
- fs.unlink(src),
41
- !isWindows && fs.chmod(dest, '0444'),
42
- ])
43
- } catch (e) {
44
- return pinflight('cacache-move-file:' + dest, async () => {
45
- await fs.stat(dest).catch((err) => {
46
- if (err.code !== 'ENOENT') {
47
- // Something else is wrong here. Bail bail bail
48
- throw err
49
- }
50
- })
51
- // file doesn't already exist! let's try a rename -> copy fallback
52
- // only delete if it successfully copies
53
- return move(src, dest)
54
- })
55
- }
56
- }