Skip to content

Commit

Permalink
chore: use esm for install script (#10987)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Sep 22, 2023
1 parent 4ea47b6 commit 3c13c05
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/issue-analyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Install dependencies Firefox
run: node ./node_modules/puppeteer/install.js
run: node ./node_modules/puppeteer/install.mjs
env:
PUPPETEER_PRODUCT: firefox
- name: Verify issue
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions packages/puppeteer/install.js → packages/puppeteer/install.mjs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

/**
* Copyright 2017 Google Inc. All rights reserved.
*
Expand All @@ -24,20 +26,18 @@
* necessary.
*/

const fs = require('fs');
const path = require('path');

// Need to ensure TS is compiled before loading the installer
if (!fs.existsSync(path.join(__dirname, 'lib'))) {
console.warn(
'Skipping browser installation because the Puppeteer build is not available. Run `npm install` again after you have re-built Puppeteer.'
);
process.exit(0);
}

try {
const {downloadBrowser} = require('puppeteer/internal/node/install.js');
const {downloadBrowser} = await (async () => {
try {
return await import('puppeteer/internal/node/install.js');
} catch {
console.warn(
'Skipping browser installation because the Puppeteer build is not available. Run `npm install` again after you have re-built Puppeteer.'
);
process.exit(0);
}
})();
downloadBrowser();
} catch (err) {
console.warn('Browser download failed', err);
} catch (error) {
console.warn('Browser download failed', error);
}
4 changes: 2 additions & 2 deletions packages/puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"build:docs": "wireit",
"build": "wireit",
"clean": "../../tools/clean.js",
"postinstall": "node install.js",
"postinstall": "node install.mjs",
"prepack": "wireit"
},
"wireit": {
Expand Down Expand Up @@ -111,7 +111,7 @@
"files": [
"lib",
"src",
"install.js",
"install.mjs",
"!*.test.js",
"!*.test.d.ts",
"!*.test.js.map",
Expand Down

0 comments on commit 3c13c05

Please sign in to comment.