Skip to content

Commit

Permalink
feat(install): build node6 support when installing from github (puppe…
Browse files Browse the repository at this point in the history
…teer#1562)

This patch starts building node6 support if puppeteer is installed from
github directly and is run under Node 6.
  • Loading branch information
aslushnikov authored Dec 9, 2017
1 parent fc1f15e commit f19e2ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ install:
yarn run coverage &&
yarn run test-doclint
) else (
yarn run build &&
yarn run unit-node6
)
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ script:
- 'if [ "$NODE7" = "true" ]; then yarn run lint; fi'
- 'if [ "$NODE7" = "true" ]; then yarn run coverage; fi'
- 'if [ "$NODE7" = "true" ]; then yarn run test-doclint; fi'
- 'if [ "$NODE6" = "true" ]; then yarn run build; fi'
- 'if [ "$NODE6" = "true" ]; then yarn run unit-node6; fi'
jobs:
include:
Expand Down
23 changes: 23 additions & 0 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

buildNode6IfNecessary();

if (process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD) {
console.log('**INFO** Skipping Chromium download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.');
return;
Expand Down Expand Up @@ -92,3 +94,24 @@ function toMegabytes(bytes) {
return `${Math.round(mb * 10) / 10} Mb`;
}

function buildNode6IfNecessary() {
const fs = require('fs');
const path = require('path');

// if this package is installed from NPM, then it already has up-to-date node6
// folder.
if (!fs.existsSync(path.join('utils', 'node6-transform')))
return;
let asyncawait = true;
try {
new Function('async function test(){await 1}');
} catch (error) {
asyncawait = false;
}
// if async/await is supported, then node6 is not needed.
if (asyncawait)
return;
// Re-build node6/ folder.
console.log('Building Puppeteer for Node 6');
require(path.join(__dirname, 'utils', 'node6-transform'));
}

0 comments on commit f19e2ad

Please sign in to comment.