mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: check if executable exists (#11946)
This commit is contained in:
parent
03ef7a62c2
commit
e95a308c33
@ -140,15 +140,22 @@ export async function install(
|
||||
options.platform,
|
||||
options.buildId
|
||||
);
|
||||
if (existsSync(outputPath)) {
|
||||
return new InstalledBrowser(
|
||||
cache,
|
||||
options.browser,
|
||||
options.buildId,
|
||||
options.platform
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
if (existsSync(outputPath)) {
|
||||
const installedBrowser = new InstalledBrowser(
|
||||
cache,
|
||||
options.browser,
|
||||
options.buildId,
|
||||
options.platform
|
||||
);
|
||||
if (!existsSync(installedBrowser.executablePath)) {
|
||||
throw new Error(
|
||||
`The browser folder (${outputPath}) exists but the executable (${installedBrowser.executablePath}) is missing`
|
||||
);
|
||||
}
|
||||
return installedBrowser;
|
||||
}
|
||||
debugInstall(`Downloading binary from ${url}`);
|
||||
try {
|
||||
debugTime('download');
|
||||
|
@ -63,6 +63,35 @@ describe('Chrome install', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('can detect missing executables', async function () {
|
||||
this.timeout(60000);
|
||||
const expectedOutputPath = path.join(
|
||||
tmpDir,
|
||||
'chrome',
|
||||
`${BrowserPlatform.LINUX}-${testChromeBuildId}`
|
||||
);
|
||||
fs.mkdirSync(expectedOutputPath, {recursive: true});
|
||||
assert.strictEqual(fs.existsSync(expectedOutputPath), true);
|
||||
async function installThatThrows(): Promise<Error | undefined> {
|
||||
try {
|
||||
await install({
|
||||
cacheDir: tmpDir,
|
||||
browser: Browser.CHROME,
|
||||
platform: BrowserPlatform.LINUX,
|
||||
buildId: testChromeBuildId,
|
||||
});
|
||||
return undefined;
|
||||
} catch (err) {
|
||||
return err as Error;
|
||||
}
|
||||
}
|
||||
assert.strictEqual(
|
||||
(await installThatThrows())?.message,
|
||||
`The browser folder (${expectedOutputPath}) exists but the executable (${expectedOutputPath}/chrome-linux64/chrome) is missing`
|
||||
);
|
||||
assert.strictEqual(fs.existsSync(expectedOutputPath), true);
|
||||
});
|
||||
|
||||
it('should download a buildId that is a zip archive', async function () {
|
||||
this.timeout(60000);
|
||||
const expectedOutputPath = path.join(
|
||||
|
Loading…
Reference in New Issue
Block a user