fix(cli.js): audit (#1989)

This commit is contained in:
Lucas Fernandes Nogueira
2021-06-15 23:00:49 -03:00
committed by GitHub
parent 546f4cc4cd
commit a819f5c9cf
4 changed files with 250 additions and 771 deletions

View File

@@ -107,6 +107,8 @@
},
"resolutions": {
"**/lodash": "4.17.21",
"**/hosted-git-info": "4.0.2"
"**/hosted-git-info": "4.0.2",
"**/normalize-url": "6.0.1",
"**/trim-newlines": "3.0.1"
}
}

View File

@@ -1,51 +0,0 @@
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
// forked from https://github.com/quasarframework/quasar/blob/dev/app/lib/helpers/net.js
import net from 'net'
async function findClosestOpenPort(
port: number,
host: string
): Promise<number> {
return await isPortAvailable(port, host).then((isAvailable) => {
if (isAvailable) {
return port
} else if (port < 65535) {
return findClosestOpenPort(port + 1, host)
} else {
throw new Error('ERROR_NETWORK_PORT_NOT_AVAIL')
}
})
}
async function isPortAvailable(port: number, host: string): Promise<boolean> {
return await new Promise((resolve, reject) => {
const tester = net
.createServer()
.once('error', (err: NodeJS.ErrnoException) => {
if (err.code === 'EADDRNOTAVAIL') {
reject(new Error('ERROR_NETWORK_ADDRESS_NOT_AVAIL'))
} else if (err.code === 'EADDRINUSE') {
resolve(false) // host/port in use
} else {
reject(err)
}
})
.once('listening', () => {
tester
.once('close', () => {
resolve(true) // found available host/port
})
.close()
})
.on('error', (err: any) => {
reject(err)
})
.listen(port, host)
})
}
export { findClosestOpenPort, isPortAvailable }

View File

@@ -36,10 +36,10 @@ export const spawn = (
}
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
onClose && onClose(code ?? 0, runner.pid)
onClose && onClose(code ?? 0, runner.pid ?? 0)
})
return runner.pid
return runner.pid ?? 0
}
/*

File diff suppressed because it is too large Load Diff