Skip to content

Commit

Permalink
fix: fix download for 1.9 (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored Mar 5, 2021
1 parent ab1fec3 commit 03e4431
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"merge-options": "^3.0.4",
"ora": "^5.3.0",
"path-browserify": "^1.0.1",
"playwright-core": "1.8.1",
"playwright-core": "1.9.1",
"polka": "^0.5.2",
"premove": "^3.0.1",
"process": "^0.11.10",
Expand Down
9 changes: 4 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,20 @@ const redirectConsole = async (msg) => {
};

const getPw = async (browserName) => {
const cachePath = path.join(process.cwd(), 'node_modules', '.cache');

const { installBrowsersWithProgressBar } = require('playwright-core/lib/install/installer');
const setupInProcess = require('playwright-core/lib/inprocess');
const browsers = require('playwright-core/browsers.json');
const browsersPath = require.resolve('playwright-core/browsers.json');

browsers.browsers[0].download = true; // chromium
browsers.browsers[1].download = true; // firefox
browsers.browsers[2].download = true; // webkit
fs.mkdirSync(cachePath, { recursive: true });

fs.writeFileSync(
path.join(cachePath, 'browsers.json'),
browsersPath,
JSON.stringify(browsers, null, 2)
);
await installBrowsersWithProgressBar(cachePath, [browserName]);
await installBrowsersWithProgressBar([browserName]);
const api = setupInProcess;

return api[browserName];
Expand Down

0 comments on commit 03e4431

Please sign in to comment.