mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
This commit is contained in:
parent
51a7b8f27f
commit
c5b3bf1d8a
@ -1018,12 +1018,10 @@ export class Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async install(executablesToInstall: Executable[], forceReinstall: boolean) {
|
async install(executablesToInstall: Executable[], forceReinstall: boolean) {
|
||||||
if (!process.env.PLAYWRIGHT_USE_INSTALLATION_LOCK)
|
const executables = this._dedupe(executablesToInstall);
|
||||||
return await this._installImpl(executablesToInstall, forceReinstall);
|
|
||||||
|
|
||||||
// TODO: Remove the following if we have confidence that we don't need the lock anymore.
|
|
||||||
await fs.promises.mkdir(registryDirectory, { recursive: true });
|
await fs.promises.mkdir(registryDirectory, { recursive: true });
|
||||||
const lockfilePath = path.join(registryDirectory, '__dirlock');
|
const lockfilePath = path.join(registryDirectory, '__dirlock');
|
||||||
|
const linksDir = path.join(registryDirectory, '.links');
|
||||||
|
|
||||||
let releaseLock;
|
let releaseLock;
|
||||||
try {
|
try {
|
||||||
@ -1040,37 +1038,6 @@ export class Registry {
|
|||||||
},
|
},
|
||||||
lockfilePath,
|
lockfilePath,
|
||||||
});
|
});
|
||||||
await this._installImpl(executablesToInstall, forceReinstall);
|
|
||||||
} catch (e) {
|
|
||||||
if (e.code === 'ELOCKED') {
|
|
||||||
const rmCommand = process.platform === 'win32' ? 'rm -R' : 'rm -rf';
|
|
||||||
throw new Error('\n' + wrapInASCIIBox([
|
|
||||||
`An active lockfile is found at:`,
|
|
||||||
``,
|
|
||||||
` ${lockfilePath}`,
|
|
||||||
``,
|
|
||||||
`Either:`,
|
|
||||||
`- wait a few minutes if other Playwright is installing browsers in parallel`,
|
|
||||||
`- remove lock manually with:`,
|
|
||||||
``,
|
|
||||||
` ${rmCommand} ${lockfilePath}`,
|
|
||||||
``,
|
|
||||||
`<3 Playwright Team`,
|
|
||||||
].join('\n'), 1));
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (releaseLock)
|
|
||||||
await releaseLock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async _installImpl(executablesToInstall: Executable[], forceReinstall: boolean) {
|
|
||||||
const executables = this._dedupe(executablesToInstall);
|
|
||||||
await fs.promises.mkdir(registryDirectory, { recursive: true });
|
|
||||||
const linksDir = path.join(registryDirectory, '.links');
|
|
||||||
|
|
||||||
// Create a link first, so that cache validation does not remove our own browsers.
|
// Create a link first, so that cache validation does not remove our own browsers.
|
||||||
await fs.promises.mkdir(linksDir, { recursive: true });
|
await fs.promises.mkdir(linksDir, { recursive: true });
|
||||||
await fs.promises.writeFile(path.join(linksDir, calculateSha1(PACKAGE_PATH)), PACKAGE_PATH);
|
await fs.promises.writeFile(path.join(linksDir, calculateSha1(PACKAGE_PATH)), PACKAGE_PATH);
|
||||||
@ -1104,6 +1071,29 @@ export class Registry {
|
|||||||
}
|
}
|
||||||
await executable._install();
|
await executable._install();
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code === 'ELOCKED') {
|
||||||
|
const rmCommand = process.platform === 'win32' ? 'rm -R' : 'rm -rf';
|
||||||
|
throw new Error('\n' + wrapInASCIIBox([
|
||||||
|
`An active lockfile is found at:`,
|
||||||
|
``,
|
||||||
|
` ${lockfilePath}`,
|
||||||
|
``,
|
||||||
|
`Either:`,
|
||||||
|
`- wait a few minutes if other Playwright is installing browsers in parallel`,
|
||||||
|
`- remove lock manually with:`,
|
||||||
|
``,
|
||||||
|
` ${rmCommand} ${lockfilePath}`,
|
||||||
|
``,
|
||||||
|
`<3 Playwright Team`,
|
||||||
|
].join('\n'), 1));
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (releaseLock)
|
||||||
|
await releaseLock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async uninstall(all: boolean): Promise<{ numberOfBrowsersLeft: number }> {
|
async uninstall(all: boolean): Promise<{ numberOfBrowsersLeft: number }> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user