perf: cache electron executable path
This commit is contained in:
parent
c6bade23b5
commit
cd0bbb6cfb
|
@ -20,18 +20,23 @@ const ensureElectronEntryFile = (root = process.cwd()): void => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getElectronPath = (): string => {
|
export const getElectronPath = (): string => {
|
||||||
const electronModulePath = path.resolve(process.cwd(), 'node_modules', 'electron')
|
let electronExecPath = process.env.ELECTRON_EXEC_PATH || ''
|
||||||
const pathFile = path.join(electronModulePath, 'path.txt')
|
if (!electronExecPath) {
|
||||||
let executablePath
|
const electronModulePath = path.resolve(process.cwd(), 'node_modules', 'electron')
|
||||||
if (fs.existsSync(pathFile)) {
|
const pathFile = path.join(electronModulePath, 'path.txt')
|
||||||
executablePath = fs.readFileSync(pathFile, 'utf-8')
|
let executablePath
|
||||||
}
|
if (fs.existsSync(pathFile)) {
|
||||||
if (executablePath) {
|
executablePath = fs.readFileSync(pathFile, 'utf-8')
|
||||||
return path.join(electronModulePath, 'dist', executablePath)
|
}
|
||||||
} else {
|
if (executablePath) {
|
||||||
throw new Error('Electron uninstall')
|
electronExecPath = path.join(electronModulePath, 'dist', executablePath)
|
||||||
|
process.env.ELECTRON_EXEC_PATH = electronExecPath
|
||||||
|
} else {
|
||||||
|
throw new Error('Electron uninstall')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return electronExecPath
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startElectron(root: string | undefined, logger: Logger): ChildProcessWithoutNullStreams {
|
export function startElectron(root: string | undefined, logger: Logger): ChildProcessWithoutNullStreams {
|
||||||
|
|
Loading…
Reference in a new issue