Skip to content

Commit 675d0dc

Browse files
committed
fix: use temp dir for tar extraction on all platforms
fixes #3165
1 parent 7d883b5 commit 675d0dc

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

lib/install.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ async function install (gyp, argv) {
200200
// download the tarball and extract!
201201
// Ommited on Windows if only new node.lib is required
202202

203-
// on Windows there can be file errors from tar if parallel installs
203+
// there can be file errors from tar if parallel installs
204204
// are happening (not uncommon with multiple native modules) so
205205
// extract the tarball to a temp directory first and then copy over
206-
const tarExtractDir = win ? await fs.mkdtemp(path.join(os.tmpdir(), 'node-gyp-tmp-')) : devDir
206+
const tarExtractDir = await fs.mkdtemp(path.join(os.tmpdir(), 'node-gyp-tmp-'))
207207

208208
try {
209209
if (shouldDownloadTarball) {
@@ -277,17 +277,13 @@ async function install (gyp, argv) {
277277
}
278278

279279
// copy over the files from the temp tarball extract directory to devDir
280-
if (tarExtractDir !== devDir) {
281-
await copyDirectory(tarExtractDir, devDir)
282-
}
280+
await copyDirectory(tarExtractDir, devDir)
283281
} finally {
284-
if (tarExtractDir !== devDir) {
285-
try {
286-
// try to cleanup temp dir
287-
await fs.rm(tarExtractDir, { recursive: true, maxRetries: 3 })
288-
} catch {
289-
log.warn('failed to clean up temp tarball extract directory')
290-
}
282+
try {
283+
// try to cleanup temp dir
284+
await fs.rm(tarExtractDir, { recursive: true, maxRetries: 3 })
285+
} catch {
286+
log.warn('failed to clean up temp tarball extract directory')
291287
}
292288
}
293289

0 commit comments

Comments
 (0)