Skip to content
This repository was archived by the owner on Apr 21, 2022. It is now read-only.

Commit 18d334c

Browse files
committed
try more
1 parent 4221d53 commit 18d334c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/tarballs/node.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function extract7Zip(path: string, cacheDir: string) {
101101
await qq.x(`7z x -bd -y '${path}' -o${cacheDir} > /dev/null`)
102102
}
103103

104-
async function cacheNode({url, cacheFileName, sha, downloadFileName, cacheDir, files}: CacheNodeOptions) {
104+
async function cacheNode({url, cacheFileName, sha, downloadFileName, files}: CacheNodeOptions) {
105105
const stream = await getDownloadResponseStream(url)
106106
const tmpDir = await promisify(tmp.dir)()
107107
await qq.mkdirp(tmpDir)
@@ -120,15 +120,16 @@ async function cacheNode({url, cacheFileName, sha, downloadFileName, cacheDir, f
120120
throw new Error(`node.js download SHASUM mismatch: expected ${url} to have shasum of ${sha}, but got ${tarballSha}`)
121121
}
122122

123-
if (url.endsWith('7z')) {
124-
const ztmpdir = await promisify(tmp.dir)()
123+
const ztmpdir = await promisify(tmp.dir)()
125124

125+
if (url.endsWith('7z')) {
126126
await qq.mkdirp(ztmpdir)
127127
await extract7Zip(tmpFile, ztmpdir)
128128

129129
await qq.mv(path.join(ztmpdir, path.basename(tmpFile, '.7z'), 'node.exe'), cacheFileName)
130130
} else {
131-
await tar.extract({file: tmpFile, cwd: cacheDir}, files)
131+
await tar.extract({file: tmpFile, cwd: ztmpdir, stripComponents: 1}, files)
132+
await qq.mv(path.join(ztmpdir, 'bin', 'node'), cacheFileName)
132133
}
133134
} finally {
134135
cacheWriteStream.close()

0 commit comments

Comments
 (0)