chore: fix dangling promise in npm install (#36379)
* Fix dangling promise introduced in #33979 * fix reject in callback * simplify code Co-authored-by: Black-Hole <158blackhole@gmail.com> Co-authored-by: Black-Hole <158blackhole@gmail.com>
This commit is contained in:
parent
7529ebfe0e
commit
9c48992e21
1 changed files with 12 additions and 20 deletions
|
@ -70,11 +70,9 @@ function isInstalled () {
|
||||||
|
|
||||||
// unzips and makes path.txt point at the correct executable
|
// unzips and makes path.txt point at the correct executable
|
||||||
function extractFile (zipPath) {
|
function extractFile (zipPath) {
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist');
|
const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist');
|
||||||
|
|
||||||
extract(zipPath, { dir: path.join(__dirname, 'dist') })
|
return extract(zipPath, { dir: path.join(__dirname, 'dist') }).then(() => {
|
||||||
.then(() => {
|
|
||||||
// If the zip contains an "electron.d.ts" file,
|
// If the zip contains an "electron.d.ts" file,
|
||||||
// move that up
|
// move that up
|
||||||
const srcTypeDefPath = path.join(distPath, 'electron.d.ts');
|
const srcTypeDefPath = path.join(distPath, 'electron.d.ts');
|
||||||
|
@ -82,17 +80,11 @@ function extractFile (zipPath) {
|
||||||
const hasTypeDefinitions = fs.existsSync(srcTypeDefPath);
|
const hasTypeDefinitions = fs.existsSync(srcTypeDefPath);
|
||||||
|
|
||||||
if (hasTypeDefinitions) {
|
if (hasTypeDefinitions) {
|
||||||
try {
|
|
||||||
fs.renameSync(srcTypeDefPath, targetTypeDefPath);
|
fs.renameSync(srcTypeDefPath, targetTypeDefPath);
|
||||||
} catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write a "path.txt" file.
|
// Write a "path.txt" file.
|
||||||
return fs.promises.writeFile(path.join(__dirname, 'path.txt'), platformPath);
|
return fs.promises.writeFile(path.join(__dirname, 'path.txt'), platformPath);
|
||||||
})
|
|
||||||
.catch((err) => reject(err));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue