fix: downloadPath should be used by the install script (#10163)
This commit is contained in:
parent
c00cf45009
commit
4398f66f28
@ -22,7 +22,7 @@ export interface Configuration
|
||||
| cacheDirectory | <code>optional</code> | string | <p>Defines the directory to be used by Puppeteer for caching.</p><p>Can be overridden by <code>PUPPETEER_CACHE_DIR</code>.</p> | <code>path.join(os.homedir(), '.cache', 'puppeteer')</code> |
|
||||
| defaultProduct | <code>optional</code> | [Product](./puppeteer.product.md) | <p>Specifies which browser you'd like Puppeteer to use.</p><p>Can be overridden by <code>PUPPETEER_PRODUCT</code>.</p> | <code>chrome</code> |
|
||||
| downloadBaseUrl | <code>optional</code> | string | <p>Specifies the URL prefix that is used to download the browser.</p><p>Can be overridden by <code>PUPPETEER_DOWNLOAD_BASE_URL</code>.</p> | Either https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing or https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central, depending on the product. |
|
||||
| downloadPath | <code>optional</code> | string | <p>Specifies the path for the downloads folder.</p><p>Can be overridden by <code>PUPPETEER_DOWNLOAD_PATH</code>.</p> | <code><cache>/<product></code> where <code><cache></code> is Puppeteer's cache directory and <code><product></code> is the name of the browser. |
|
||||
| downloadPath | <code>optional</code> | string | <p>Specifies the path for the downloads folder.</p><p>Can be overridden by <code>PUPPETEER_DOWNLOAD_PATH</code>.</p> | <code><cacheDirectory></code> |
|
||||
| executablePath | <code>optional</code> | string | <p>Specifies an executable path to be used in [puppeteer.launch](./puppeteer.puppeteernode.launch.md).</p><p>Can be overridden by <code>PUPPETEER_EXECUTABLE_PATH</code>.</p> | **Auto-computed.** |
|
||||
| experiments | <code>optional</code> | [ExperimentsConfiguration](./puppeteer.experimentsconfiguration.md) | Defines experimental options for Puppeteer. | |
|
||||
| logLevel | <code>optional</code> | 'silent' \| 'error' \| 'warn' | Tells Puppeteer to log at the given level. | <code>warn</code> |
|
||||
|
@ -71,8 +71,7 @@ export interface Configuration {
|
||||
*
|
||||
* Can be overridden by `PUPPETEER_DOWNLOAD_PATH`.
|
||||
*
|
||||
* @defaultValue `<cache>/<product>` where `<cache>` is Puppeteer's cache
|
||||
* directory and `<product>` is the name of the browser.
|
||||
* @defaultValue `<cacheDirectory>`
|
||||
*/
|
||||
downloadPath?: string;
|
||||
/**
|
||||
|
@ -60,11 +60,13 @@ export async function downloadBrowser(): Promise<void> {
|
||||
configuration.browserRevision || PUPPETEER_REVISIONS[product] || 'latest';
|
||||
|
||||
const buildId = await resolveBuildId(browser, platform, unresolvedBuildId);
|
||||
// TODO: deprecate downloadPath in favour of cacheDirectory.
|
||||
const cacheDir = configuration.downloadPath ?? configuration.cacheDirectory!;
|
||||
|
||||
try {
|
||||
const result = await install({
|
||||
browser,
|
||||
cacheDir: configuration.cacheDirectory!,
|
||||
cacheDir,
|
||||
platform,
|
||||
buildId,
|
||||
downloadProgressCallback: makeProgressCallback(browser, buildId),
|
||||
|
@ -44,3 +44,23 @@ describe('`puppeteer`', () => {
|
||||
await this.runScript(script, 'mjs');
|
||||
});
|
||||
});
|
||||
|
||||
describe('`puppeteer` with PUPPETEER_DOWNLOAD_PATH', () => {
|
||||
configureSandbox({
|
||||
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
||||
env: cwd => {
|
||||
return {
|
||||
PUPPETEER_DOWNLOAD_PATH: join(cwd, '.cache', 'puppeteer'),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
it('evaluates', async function () {
|
||||
const files = await readdir(join(this.sandbox, '.cache', 'puppeteer'));
|
||||
assert.equal(files.length, 1);
|
||||
assert.equal(files[0], 'chrome');
|
||||
|
||||
const script = await readAsset('puppeteer', 'basic.js');
|
||||
await this.runScript(script, 'mjs');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user