pnpm 7.9.1 → 7.9.2
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.
- package/README.md +22 -7
- package/bin/pnpm.cjs +3 -0
- package/bin/pnpx.cjs +1 -15
- package/dist/node_modules/.modules.yaml +3 -3
- package/dist/node_modules/.pnpm/lock.yaml +76 -42
- package/dist/node_modules/@npmcli/fs/lib/common/owner-sync.js +96 -0
- package/dist/node_modules/@npmcli/fs/lib/common/owner.js +8 -4
- package/dist/node_modules/@npmcli/fs/lib/copy-file.js +3 -9
- package/dist/node_modules/@npmcli/fs/lib/fs.js +9 -3
- package/dist/node_modules/@npmcli/fs/lib/index.js +3 -1
- package/dist/node_modules/@npmcli/fs/lib/mkdir.js +19 -0
- package/dist/node_modules/@npmcli/fs/lib/mkdtemp.js +3 -8
- package/dist/node_modules/@npmcli/fs/lib/with-owner-sync.js +21 -0
- package/dist/node_modules/@npmcli/fs/lib/with-owner.js +21 -0
- package/dist/node_modules/@npmcli/fs/lib/with-temp-dir.js +4 -2
- package/dist/node_modules/@npmcli/fs/lib/write-file.js +3 -8
- package/dist/node_modules/@npmcli/fs/package.json +21 -9
- package/dist/node_modules/@npmcli/move-file/{index.js → lib/index.js} +50 -27
- package/dist/node_modules/@npmcli/move-file/package.json +20 -7
- package/dist/node_modules/@tootallnate/once/LICENSE +21 -0
- package/dist/node_modules/@tootallnate/once/dist/index.js +21 -36
- package/dist/node_modules/@tootallnate/once/dist/index.js.map +1 -1
- package/dist/node_modules/@tootallnate/once/dist/overloaded-parameters.js +3 -0
- package/dist/node_modules/@tootallnate/once/dist/overloaded-parameters.js.map +1 -0
- package/dist/node_modules/@tootallnate/once/dist/types.js +3 -0
- package/dist/node_modules/@tootallnate/once/dist/types.js.map +1 -0
- package/dist/node_modules/@tootallnate/once/package.json +22 -15
- package/dist/node_modules/cacache/lib/content/read.js +99 -102
- package/dist/node_modules/cacache/lib/content/rm.js +9 -8
- package/dist/node_modules/cacache/lib/content/write.js +67 -67
- package/dist/node_modules/cacache/lib/entry-index.js +128 -118
- package/dist/node_modules/cacache/{get.js → lib/get.js} +88 -100
- package/dist/node_modules/cacache/{index.js → lib/index.js} +5 -6
- package/dist/node_modules/cacache/lib/memoization.js +10 -11
- package/dist/node_modules/cacache/{put.js → lib/put.js} +23 -26
- package/dist/node_modules/cacache/{rm.js → lib/rm.js} +3 -3
- package/dist/node_modules/cacache/lib/util/fix-owner.js +41 -38
- package/dist/node_modules/cacache/lib/util/move-file.js +36 -47
- package/dist/node_modules/cacache/lib/util/tmp.js +5 -7
- package/dist/node_modules/cacache/lib/verify.js +160 -190
- package/dist/node_modules/cacache/node_modules/brace-expansion/.github/FUNDING.yml +2 -0
- package/dist/node_modules/cacache/node_modules/brace-expansion/LICENSE +21 -0
- package/dist/node_modules/cacache/node_modules/brace-expansion/index.js +203 -0
- package/dist/node_modules/cacache/node_modules/brace-expansion/package.json +46 -0
- package/dist/node_modules/cacache/node_modules/glob/LICENSE +15 -0
- package/dist/node_modules/cacache/node_modules/glob/common.js +240 -0
- package/dist/node_modules/cacache/node_modules/glob/glob.js +790 -0
- package/dist/node_modules/cacache/node_modules/glob/package.json +55 -0
- package/dist/node_modules/cacache/node_modules/glob/sync.js +486 -0
- package/dist/node_modules/cacache/node_modules/minimatch/LICENSE +15 -0
- package/dist/node_modules/cacache/node_modules/minimatch/lib/path.js +4 -0
- package/dist/node_modules/cacache/node_modules/minimatch/minimatch.js +906 -0
- package/dist/node_modules/cacache/node_modules/minimatch/package.json +32 -0
- package/dist/node_modules/cacache/package.json +34 -30
- package/dist/node_modules/http-proxy-agent/dist/agent.js +3 -3
- package/dist/node_modules/http-proxy-agent/dist/agent.js.map +1 -1
- package/dist/node_modules/http-proxy-agent/package.json +4 -4
- package/dist/node_modules/lru-cache/LICENSE +1 -1
- package/dist/node_modules/lru-cache/index.js +921 -247
- package/dist/node_modules/lru-cache/package.json +49 -9
- package/dist/node_modules/make-fetch-happen/LICENSE +1 -1
- package/dist/node_modules/make-fetch-happen/lib/agent.js +34 -14
- package/dist/node_modules/make-fetch-happen/lib/cache/entry.js +90 -106
- package/dist/node_modules/make-fetch-happen/lib/cache/errors.js +1 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/index.js +10 -6
- package/dist/node_modules/make-fetch-happen/lib/cache/policy.js +21 -21
- package/dist/node_modules/make-fetch-happen/lib/dns.js +49 -0
- package/dist/node_modules/make-fetch-happen/lib/fetch.js +40 -22
- package/dist/node_modules/make-fetch-happen/lib/index.js +4 -3
- package/dist/node_modules/make-fetch-happen/lib/options.js +17 -9
- package/dist/node_modules/make-fetch-happen/lib/pipeline.js +41 -0
- package/dist/node_modules/make-fetch-happen/lib/remote.js +28 -9
- package/dist/node_modules/make-fetch-happen/package.json +36 -33
- package/dist/node_modules/minipass-fetch/lib/blob.js +4 -4
- package/dist/node_modules/minipass-fetch/lib/body.js +63 -49
- package/dist/node_modules/minipass-fetch/lib/fetch-error.js +2 -1
- package/dist/node_modules/minipass-fetch/lib/headers.js +38 -21
- package/dist/node_modules/minipass-fetch/lib/index.js +130 -106
- package/dist/node_modules/minipass-fetch/lib/request.js +46 -28
- package/dist/node_modules/minipass-fetch/lib/response.js +3 -2
- package/dist/node_modules/minipass-fetch/package.json +27 -14
- package/dist/node_modules/node-gyp/.github/workflows/release-please.yml +1 -1
- package/dist/node_modules/node-gyp/.github/workflows/tests.yml +16 -9
- package/dist/node_modules/node-gyp/.github/workflows/visual-studio.yml +16 -8
- package/dist/node_modules/node-gyp/lib/build.js +7 -0
- package/dist/node_modules/node-gyp/lib/configure.js +26 -1
- package/dist/node_modules/node-gyp/lib/create-config-gypi.js +2 -1
- package/dist/node_modules/node-gyp/lib/find-visualstudio.js +9 -8
- package/dist/node_modules/node-gyp/lib/node-gyp.js +4 -0
- package/dist/node_modules/node-gyp/package.json +4 -4
- package/dist/node_modules/semver/node_modules/lru-cache/LICENSE +15 -0
- package/dist/node_modules/semver/node_modules/lru-cache/index.js +334 -0
- package/dist/node_modules/semver/node_modules/lru-cache/package.json +34 -0
- package/dist/node_modules/socks-proxy-agent/dist/index.js +3 -3
- package/dist/node_modules/socks-proxy-agent/dist/index.js.map +1 -1
- package/dist/node_modules/socks-proxy-agent/package.json +2 -2
- package/dist/node_modules/ssri/{index.js → lib/index.js} +78 -24
- package/dist/node_modules/ssri/package.json +27 -16
- package/dist/pnpm.cjs +67042 -65886
- package/package.json +6 -6
- package/dist/node_modules/@npmcli/fs/lib/common/file-url-to-path/index.js +0 -17
- package/dist/node_modules/@npmcli/fs/lib/common/file-url-to-path/polyfill.js +0 -121
- package/dist/node_modules/@npmcli/fs/lib/mkdir/index.js +0 -32
- package/dist/node_modules/@npmcli/fs/lib/mkdir/polyfill.js +0 -81
- package/dist/node_modules/cacache/lib/util/disposer.js +0 -30
- package/dist/node_modules/cacache/ls.js +0 -6
- package/dist/node_modules/cacache/verify.js +0 -3
- package/dist/node_modules/minipass-fetch/index.js +0 -1
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const ls = require('./ls.js')
|
|
4
3
|
const get = require('./get.js')
|
|
5
4
|
const put = require('./put.js')
|
|
6
5
|
const rm = require('./rm.js')
|
|
7
6
|
const verify = require('./verify.js')
|
|
8
|
-
const { clearMemoized } = require('./
|
|
9
|
-
const tmp = require('./
|
|
10
|
-
const index = require('./
|
|
7
|
+
const { clearMemoized } = require('./memoization.js')
|
|
8
|
+
const tmp = require('./util/tmp.js')
|
|
9
|
+
const index = require('./entry-index.js')
|
|
11
10
|
|
|
12
11
|
module.exports.index = {}
|
|
13
12
|
module.exports.index.compact = index.compact
|
|
14
13
|
module.exports.index.insert = index.insert
|
|
15
14
|
|
|
16
|
-
module.exports.ls = ls
|
|
17
|
-
module.exports.ls.stream =
|
|
15
|
+
module.exports.ls = index.ls
|
|
16
|
+
module.exports.ls.stream = index.lsStream
|
|
18
17
|
|
|
19
18
|
module.exports.get = get
|
|
20
19
|
module.exports.get.byDigest = get.byDigest
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const LRU = require('lru-cache')
|
|
4
4
|
|
|
5
|
-
const MAX_SIZE = 50 * 1024 * 1024 // 50MB
|
|
6
|
-
const MAX_AGE = 3 * 60 * 1000
|
|
7
|
-
|
|
8
5
|
const MEMOIZED = new LRU({
|
|
9
|
-
max:
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
max: 500,
|
|
7
|
+
maxSize: 50 * 1024 * 1024, // 50MB
|
|
8
|
+
ttl: 3 * 60 * 1000, // 3 minutes
|
|
9
|
+
sizeCalculation: (entry, key) => key.startsWith('key:') ? entry.data.length : entry.length,
|
|
12
10
|
})
|
|
13
11
|
|
|
14
12
|
module.exports.clearMemoized = clearMemoized
|
|
@@ -18,7 +16,7 @@ function clearMemoized () {
|
|
|
18
16
|
MEMOIZED.forEach((v, k) => {
|
|
19
17
|
old[k] = v
|
|
20
18
|
})
|
|
21
|
-
MEMOIZED.
|
|
19
|
+
MEMOIZED.clear()
|
|
22
20
|
return old
|
|
23
21
|
}
|
|
24
22
|
|
|
@@ -62,12 +60,13 @@ class ObjProxy {
|
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
function pickMem (opts) {
|
|
65
|
-
if (!opts || !opts.memoize)
|
|
63
|
+
if (!opts || !opts.memoize) {
|
|
66
64
|
return MEMOIZED
|
|
67
|
-
else if (opts.memoize.get && opts.memoize.set)
|
|
65
|
+
} else if (opts.memoize.get && opts.memoize.set) {
|
|
68
66
|
return opts.memoize
|
|
69
|
-
else if (typeof opts.memoize === 'object')
|
|
67
|
+
} else if (typeof opts.memoize === 'object') {
|
|
70
68
|
return new ObjProxy(opts.memoize)
|
|
71
|
-
else
|
|
69
|
+
} else {
|
|
72
70
|
return MEMOIZED
|
|
71
|
+
}
|
|
73
72
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const index = require('./
|
|
4
|
-
const memo = require('./
|
|
5
|
-
const write = require('./
|
|
3
|
+
const index = require('./entry-index')
|
|
4
|
+
const memo = require('./memoization')
|
|
5
|
+
const write = require('./content/write')
|
|
6
6
|
const Flush = require('minipass-flush')
|
|
7
7
|
const { PassThrough } = require('minipass-collect')
|
|
8
8
|
const Pipeline = require('minipass-pipeline')
|
|
@@ -14,19 +14,16 @@ const putOpts = (opts) => ({
|
|
|
14
14
|
|
|
15
15
|
module.exports = putData
|
|
16
16
|
|
|
17
|
-
function putData (cache, key, data, opts = {}) {
|
|
17
|
+
async function putData (cache, key, data, opts = {}) {
|
|
18
18
|
const { memoize } = opts
|
|
19
19
|
opts = putOpts(opts)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
memo.put(cache, entry, data, opts)
|
|
20
|
+
const res = await write(cache, data, opts)
|
|
21
|
+
const entry = await index.insert(cache, key, res.integrity, { ...opts, size: res.size })
|
|
22
|
+
if (memoize) {
|
|
23
|
+
memo.put(cache, entry, data, opts)
|
|
24
|
+
}
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
})
|
|
26
|
+
return res.integrity
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
module.exports.stream = putStream
|
|
@@ -36,6 +33,7 @@ function putStream (cache, key, opts = {}) {
|
|
|
36
33
|
opts = putOpts(opts)
|
|
37
34
|
let integrity
|
|
38
35
|
let size
|
|
36
|
+
let error
|
|
39
37
|
|
|
40
38
|
let memoData
|
|
41
39
|
const pipeline = new Pipeline()
|
|
@@ -57,25 +55,24 @@ function putStream (cache, key, opts = {}) {
|
|
|
57
55
|
.on('size', (s) => {
|
|
58
56
|
size = s
|
|
59
57
|
})
|
|
58
|
+
.on('error', (err) => {
|
|
59
|
+
error = err
|
|
60
|
+
})
|
|
60
61
|
|
|
61
62
|
pipeline.push(contentStream)
|
|
62
63
|
|
|
63
64
|
// last but not least, we write the index and emit hash and size,
|
|
64
65
|
// and memoize if we're doing that
|
|
65
66
|
pipeline.push(new Flush({
|
|
66
|
-
flush () {
|
|
67
|
-
|
|
68
|
-
.insert(cache, key, integrity, { ...opts, size })
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (size)
|
|
77
|
-
pipeline.emit('size', size)
|
|
78
|
-
})
|
|
67
|
+
async flush () {
|
|
68
|
+
if (!error) {
|
|
69
|
+
const entry = await index.insert(cache, key, integrity, { ...opts, size })
|
|
70
|
+
if (memoize && memoData) {
|
|
71
|
+
memo.put(cache, entry, memoData, opts)
|
|
72
|
+
}
|
|
73
|
+
pipeline.emit('integrity', integrity)
|
|
74
|
+
pipeline.emit('size', size)
|
|
75
|
+
}
|
|
79
76
|
},
|
|
80
77
|
}))
|
|
81
78
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const util = require('util')
|
|
4
4
|
|
|
5
|
-
const index = require('./
|
|
6
|
-
const memo = require('./
|
|
5
|
+
const index = require('./entry-index')
|
|
6
|
+
const memo = require('./memoization')
|
|
7
7
|
const path = require('path')
|
|
8
8
|
const rimraf = util.promisify(require('rimraf'))
|
|
9
|
-
const rmContent = require('./
|
|
9
|
+
const rmContent = require('./content/rm')
|
|
10
10
|
|
|
11
11
|
module.exports = entry
|
|
12
12
|
module.exports.entry = entry
|
|
@@ -33,38 +33,38 @@ const getSelf = () => {
|
|
|
33
33
|
|
|
34
34
|
module.exports.chownr = fixOwner
|
|
35
35
|
|
|
36
|
-
function fixOwner (cache, filepath) {
|
|
36
|
+
async function fixOwner (cache, filepath) {
|
|
37
37
|
if (!process.getuid) {
|
|
38
38
|
// This platform doesn't need ownership fixing
|
|
39
|
-
return
|
|
39
|
+
return
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
getSelf()
|
|
43
43
|
if (self.uid !== 0) {
|
|
44
44
|
// almost certainly can't chown anyway
|
|
45
|
-
return
|
|
45
|
+
return
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
const { uid, gid } = owner
|
|
48
|
+
const { uid, gid } = await inferOwner(cache)
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
// No need to override if it's already what we used.
|
|
51
|
+
if (self.uid === uid && self.gid === gid) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return inflight('fixOwner: fixing ownership on ' + filepath, () =>
|
|
56
|
+
chownr(
|
|
57
|
+
filepath,
|
|
58
|
+
typeof uid === 'number' ? uid : self.uid,
|
|
59
|
+
typeof gid === 'number' ? gid : self.gid
|
|
60
|
+
).catch((err) => {
|
|
61
|
+
if (err.code === 'ENOENT') {
|
|
62
|
+
return null
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
throw err
|
|
66
|
+
})
|
|
67
|
+
)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
module.exports.chownr.sync = fixOwnerSync
|
|
@@ -93,8 +93,9 @@ function fixOwnerSync (cache, filepath) {
|
|
|
93
93
|
)
|
|
94
94
|
} catch (err) {
|
|
95
95
|
// only catch ENOENT, any other error is a problem.
|
|
96
|
-
if (err.code === 'ENOENT')
|
|
96
|
+
if (err.code === 'ENOENT') {
|
|
97
97
|
return null
|
|
98
|
+
}
|
|
98
99
|
|
|
99
100
|
throw err
|
|
100
101
|
}
|
|
@@ -102,24 +103,25 @@ function fixOwnerSync (cache, filepath) {
|
|
|
102
103
|
|
|
103
104
|
module.exports.mkdirfix = mkdirfix
|
|
104
105
|
|
|
105
|
-
function mkdirfix (cache, p, cb) {
|
|
106
|
+
async function mkdirfix (cache, p, cb) {
|
|
106
107
|
// we have to infer the owner _before_ making the directory, even though
|
|
107
108
|
// we aren't going to use the results, since the cache itself might not
|
|
108
109
|
// exist yet. If we mkdirp it, then our current uid/gid will be assumed
|
|
109
110
|
// to be correct if it creates the cache folder in the process.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
111
|
+
await inferOwner(cache)
|
|
112
|
+
try {
|
|
113
|
+
const made = await mkdirp(p)
|
|
114
|
+
if (made) {
|
|
115
|
+
await fixOwner(cache, made)
|
|
116
|
+
return made
|
|
117
|
+
}
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (err.code === 'EEXIST') {
|
|
120
|
+
await fixOwner(cache, p)
|
|
121
|
+
return null
|
|
122
|
+
}
|
|
123
|
+
throw err
|
|
124
|
+
}
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
module.exports.mkdirfix.sync = mkdirfixSync
|
|
@@ -136,7 +138,8 @@ function mkdirfixSync (cache, p) {
|
|
|
136
138
|
if (err.code === 'EEXIST') {
|
|
137
139
|
fixOwnerSync(cache, p)
|
|
138
140
|
return null
|
|
139
|
-
} else
|
|
141
|
+
} else {
|
|
140
142
|
throw err
|
|
143
|
+
}
|
|
141
144
|
}
|
|
142
145
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const util = require('util')
|
|
5
|
-
const chmod = util.promisify(fs.chmod)
|
|
6
|
-
const unlink = util.promisify(fs.unlink)
|
|
7
|
-
const stat = util.promisify(fs.stat)
|
|
3
|
+
const fs = require('@npmcli/fs')
|
|
8
4
|
const move = require('@npmcli/move-file')
|
|
9
5
|
const pinflight = require('promise-inflight')
|
|
10
6
|
|
|
11
7
|
module.exports = moveFile
|
|
12
8
|
|
|
13
|
-
function moveFile (src, dest) {
|
|
14
|
-
const isWindows =
|
|
15
|
-
process.platform === 'win32'
|
|
9
|
+
async function moveFile (src, dest) {
|
|
10
|
+
const isWindows = process.platform === 'win32'
|
|
16
11
|
|
|
17
12
|
// This isn't quite an fs.rename -- the assumption is that
|
|
18
13
|
// if `dest` already exists, and we get certain errors while
|
|
@@ -23,45 +18,39 @@ function moveFile (src, dest) {
|
|
|
23
18
|
// content their own way.
|
|
24
19
|
//
|
|
25
20
|
// Note that, as the name suggests, this strictly only supports file moves.
|
|
26
|
-
|
|
27
|
-
fs.link(src, dest
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return pinflight('cacache-move-file:' + dest, () => {
|
|
56
|
-
return stat(dest).catch((err) => {
|
|
57
|
-
if (err.code !== 'ENOENT') {
|
|
58
|
-
// Something else is wrong here. Bail bail bail
|
|
59
|
-
throw err
|
|
60
|
-
}
|
|
61
|
-
// file doesn't already exist! let's try a rename -> copy fallback
|
|
62
|
-
// only delete if it successfully copies
|
|
63
|
-
return move(src, dest)
|
|
64
|
-
})
|
|
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
|
+
}
|
|
65
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)
|
|
66
54
|
})
|
|
55
|
+
}
|
|
67
56
|
}
|
|
@@ -7,15 +7,13 @@ const path = require('path')
|
|
|
7
7
|
|
|
8
8
|
module.exports.mkdir = mktmpdir
|
|
9
9
|
|
|
10
|
-
function mktmpdir (cache, opts = {}) {
|
|
10
|
+
async function mktmpdir (cache, opts = {}) {
|
|
11
11
|
const { tmpPrefix } = opts
|
|
12
12
|
const tmpDir = path.join(cache, 'tmp')
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return fs.mkdtemp(target, { owner: 'inherit' })
|
|
18
|
-
})
|
|
13
|
+
await fs.mkdir(tmpDir, { recursive: true, owner: 'inherit' })
|
|
14
|
+
// do not use path.join(), it drops the trailing / if tmpPrefix is unset
|
|
15
|
+
const target = `${tmpDir}${path.sep}${tmpPrefix || ''}`
|
|
16
|
+
return fs.mkdtemp(target, { owner: 'inherit' })
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
module.exports.withTmp = withTmp
|