Skip to content

Commit

Permalink
fix: reduce one level promise
Browse files Browse the repository at this point in the history
Windows seems to be hanging, hopefully this reduces the number of
promises in the chain.
  • Loading branch information
imatlopez committed Sep 14, 2020
1 parent 607bac5 commit 4bd289a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async function install (fs, gyp, argv) {
const installVersionPath = path.resolve(devDir, 'installVersion')
await Promise.all([
// need to download node.lib
...(win ? [downloadNodeLib()] : []),
...(win ? downloadNodeLib() : []),
// write the "installVersion" file
fs.promises.writeFile(installVersionPath, gyp.package.installVersion + '\n'),
// Only download SHASUMS.txt if we downloaded something in need of SHA verification
Expand Down Expand Up @@ -228,10 +228,10 @@ async function install (fs, gyp, argv) {
log.verbose('checksum data', JSON.stringify(expectShasums))
}

async function downloadNodeLib () {
function downloadNodeLib () {
log.verbose('on Windows; need to download `' + release.name + '.lib`...')
const archs = ['ia32', 'x64', 'arm64']
return Promise.all(archs.map(async (arch) => {
return archs.map(async (arch) => {
const dir = path.resolve(devDir, arch)
const targetLibPath = path.resolve(dir, release.name + '.lib')
const { libUrl, libPath } = release[arch]
Expand Down Expand Up @@ -264,7 +264,7 @@ async function install (fs, gyp, argv) {
}),
fs.createWriteStream(targetLibPath)
)
}))
})
} // downloadNodeLib()
} // go()

Expand Down
3 changes: 2 additions & 1 deletion test/test-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ test('download over http with proxy', (t) => {
pserver.listen(port + 1, host, async () => {
const gyp = {
opts: {
proxy: `http://${host}:${port + 1}`
proxy: `http://${host}:${port + 1}`,
noproxy: 'bad'
},
version: '42'
}
Expand Down

0 comments on commit 4bd289a

Please sign in to comment.