fix: Handle an electron.d.ts file in a custom build (#33979)
* Handle an electron.d.ts file in a custom build * Fix linter issues Co-authored-by: Felix Rieseberg <felixr@stripe.com>
This commit is contained in:
parent
c09c94fc98
commit
74d59af3c5
1 changed files with 24 additions and 2 deletions
|
@ -70,8 +70,30 @@ 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 extract(zipPath, { dir: path.join(__dirname, 'dist') })
|
return new Promise((resolve, reject) => {
|
||||||
.then(() => fs.promises.writeFile(path.join(__dirname, 'path.txt'), platformPath));
|
const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist');
|
||||||
|
|
||||||
|
extract(zipPath, { dir: path.join(__dirname, 'dist') })
|
||||||
|
.then(() => {
|
||||||
|
// If the zip contains an "electron.d.ts" file,
|
||||||
|
// move that up
|
||||||
|
const srcTypeDefPath = path.join(distPath, 'electron.d.ts');
|
||||||
|
const targetTypeDefPath = path.join(__dirname, 'electron.d.ts');
|
||||||
|
const hasTypeDefinitions = fs.existsSync(srcTypeDefPath);
|
||||||
|
|
||||||
|
if (hasTypeDefinitions) {
|
||||||
|
try {
|
||||||
|
fs.renameSync(srcTypeDefPath, targetTypeDefPath);
|
||||||
|
} catch (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write a "path.txt" file.
|
||||||
|
return fs.promises.writeFile(path.join(__dirname, 'path.txt'), platformPath);
|
||||||
|
})
|
||||||
|
.catch((err) => reject(err));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPlatformPath () {
|
function getPlatformPath () {
|
||||||
|
|
Loading…
Reference in a new issue