mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: opt-out of installation lock by default (#35436)
This commit is contained in:
parent
6405dace36
commit
49c13a0788
@ -1020,10 +1020,12 @@ export class Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async install(executablesToInstall: Executable[], forceReinstall: boolean) {
|
async install(executablesToInstall: Executable[], forceReinstall: boolean) {
|
||||||
const executables = this._dedupe(executablesToInstall);
|
if (!process.env.PLAYWRIGHT_USE_INSTALLATION_LOCK)
|
||||||
|
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,6 +1042,37 @@ 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);
|
||||||
@ -1073,29 +1106,6 @@ 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