From 8879a041c2a67803ad0b15d8f3047a5342499e47 Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Tue, 24 Jan 2017 12:37:42 -0800 Subject: [PATCH] remove support for node before v6 --- .travis.yml | 5 +-- lighthouse-cli/bin.ts | 6 --- lighthouse-cli/test/cli/index-test.js | 13 ++----- lighthouse-cli/test/smokehouse/smokehouse.js | 6 --- lighthouse-core/.npmrc | 1 - lighthouse-core/index.js | 7 ---- lighthouse-core/lib/environment.js | 39 -------------------- lighthouse-core/scripts/run-mocha.sh | 2 +- lighthouse-extension/package.json | 4 +- lighthouse-viewer/package.json | 2 +- package.json | 6 +-- readme.md | 2 +- 12 files changed, 12 insertions(+), 81 deletions(-) delete mode 100644 lighthouse-core/.npmrc delete mode 100644 lighthouse-core/lib/environment.js diff --git a/.travis.yml b/.travis.yml index 3ed684ff5dec..342b4d7c6377 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,7 @@ language: node_js matrix: include: - - node_js: "4.3.2" - - node_js: "5" - - node_js: "6" + - node_js: "6.9.1" - node_js: "7" sudo: required dist: trusty @@ -17,7 +15,6 @@ install: - npm install - npm run install-all before_script: - - if [[ $(node -v) =~ ^v4.* ]]; then export __node_harmony=--harmony; fi - export DISPLAY=:99.0 - export LIGHTHOUSE_CHROMIUM_PATH="$(pwd)/chrome-linux/chrome" - sh -e /etc/init.d/xvfb start diff --git a/lighthouse-cli/bin.ts b/lighthouse-cli/bin.ts index 55fac5a51a5a..7c42f4ed3936 100755 --- a/lighthouse-cli/bin.ts +++ b/lighthouse-cli/bin.ts @@ -21,12 +21,6 @@ const _SIGINT_EXIT_CODE = 130; const _RUNTIME_ERROR_CODE = 1; const _PROTOCOL_TIMEOUT_EXIT_CODE = 67; -const environment = require('../lighthouse-core/lib/environment.js'); -if (!environment.checkNodeCompatibility()) { - console.warn('Compatibility error', 'Lighthouse requires node 5+ or 4 with --harmony'); - process.exit(_RUNTIME_ERROR_CODE); -} - const assetSaver = require('../lighthouse-core/lib/asset-saver.js'); import {ChromeLauncher} from './chrome-launcher'; import * as Commands from './commands/commands'; diff --git a/lighthouse-cli/test/cli/index-test.js b/lighthouse-cli/test/cli/index-test.js index d7004236b2b6..ba5ec7e4890f 100644 --- a/lighthouse-cli/test/cli/index-test.js +++ b/lighthouse-cli/test/cli/index-test.js @@ -19,30 +19,23 @@ /* eslint-env mocha */ const assert = require('assert'); const childProcess = require('child_process'); -let node = 'node'; describe('CLI Tests', function() { - before(() => { - if (/^v4.*/.test(process.version)) { - node = 'node --harmony'; - } - }); - it('fails if a url is not provided', () => { - assert.throws(() => childProcess.execSync(`${node} lighthouse-cli/index.js`), + assert.throws(() => childProcess.execSync('node lighthouse-cli/index.js'), /Please provide a url/); }); it('should list all audits without a url and exit immediately after', () => { const output = JSON.parse(childProcess.execSync( - `${node} lighthouse-cli/index.js --list-all-audits`).toString()); + 'node lighthouse-cli/index.js --list-all-audits').toString()); assert.ok(Array.isArray(output.audits)); assert.ok(output.audits.length > 0); }); it('accepts just the list-trace-categories flag and exit immediately after', () => { const output = JSON.parse(childProcess.execSync( - `${node} lighthouse-cli/index.js --list-trace-categories`).toString()); + 'node lighthouse-cli/index.js --list-trace-categories').toString()); assert.ok(Array.isArray(output.traceCategories)); assert.ok(output.traceCategories.length > 0); }); diff --git a/lighthouse-cli/test/smokehouse/smokehouse.js b/lighthouse-cli/test/smokehouse/smokehouse.js index 23757eb9ac78..1014e725b1d7 100755 --- a/lighthouse-cli/test/smokehouse/smokehouse.js +++ b/lighthouse-cli/test/smokehouse/smokehouse.js @@ -66,12 +66,6 @@ function runLighthouse(url, configPath) { '--port=0' ]; - // Assume if currently running in Node v4 that child process will as well, so - // run Lighthouse with --harmony flag. - if (/v4/.test(process.version)) { - args.unshift('--harmony'); - } - // Lighthouse sometimes times out waiting to for a connection to Chrome in CI. // Watch for this error and retry relaunching Chrome and running Lighthouse up // to RETRIES times. See https://github.com/GoogleChrome/lighthouse/issues/833 diff --git a/lighthouse-core/.npmrc b/lighthouse-core/.npmrc deleted file mode 100644 index 14253b2444c2..000000000000 --- a/lighthouse-core/.npmrc +++ /dev/null @@ -1 +0,0 @@ -harmony = "" diff --git a/lighthouse-core/index.js b/lighthouse-core/index.js index cfcda0aaeceb..84bc4d39ae95 100644 --- a/lighthouse-core/index.js +++ b/lighthouse-core/index.js @@ -17,13 +17,6 @@ 'use strict'; -const environment = require('../lighthouse-core/lib/environment'); -if (!environment.checkNodeCompatibility()) { - // eslint-disable-next-line no-console - console.warn('Compatibility error', 'Lighthouse requires node 5+ or 4 with --harmony'); - process.exit(1); -} - const Runner = require('./runner'); const log = require('./lib/log.js'); const ChromeProtocol = require('./gather/connections/cri.js'); diff --git a/lighthouse-core/lib/environment.js b/lighthouse-core/lib/environment.js deleted file mode 100644 index b788cd0e95ce..000000000000 --- a/lighthouse-core/lib/environment.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; - -const semver = require('semver'); -const vm = require('vm'); - -function checkNodeCompatibility() { - // node 5.x required due to use of ES2015 features, like spread operator - if (semver.gte(process.version, '5.0.0')) { - return true; - } - - try { - // Test for the availability of the spread operator. - new vm.Script('Math.max(...[ 5, 10 ])').runInThisContext(); - return true; - } catch (e) { - return false; - } -} - -module.exports = { - checkNodeCompatibility: checkNodeCompatibility -}; diff --git a/lighthouse-core/scripts/run-mocha.sh b/lighthouse-core/scripts/run-mocha.sh index f8c907a2bb8b..d410c898b32b 100755 --- a/lighthouse-core/scripts/run-mocha.sh +++ b/lighthouse-core/scripts/run-mocha.sh @@ -3,7 +3,7 @@ flag=$1 function _runmocha() { - mocha $2 $__node_harmony $(find $1/test -name '*-test.js') --timeout 60000; + mocha $2 $(find $1/test -name '*-test.js') --timeout 60000; } if [ "$flag" == '--watch' ]; then diff --git a/lighthouse-extension/package.json b/lighthouse-extension/package.json index af022f6950bd..2c802fa724f9 100644 --- a/lighthouse-extension/package.json +++ b/lighthouse-extension/package.json @@ -2,11 +2,11 @@ "name": "lighthouse-extension", "private": true, "engines": { - "node": ">=0.8.0" + "node": ">=6" }, "scripts": { "watch": "gulp watch", - "build": "gulp build -- $__node_harmony" + "build": "gulp build" }, "devDependencies": { "brfs": "^1.4.3", diff --git a/lighthouse-viewer/package.json b/lighthouse-viewer/package.json index 6e2ca320c6f4..2012df9aa75a 100644 --- a/lighthouse-viewer/package.json +++ b/lighthouse-viewer/package.json @@ -2,7 +2,7 @@ "name": "lighthouse-viewer", "private": true, "engines": { - "node": ">=5" + "node": ">=6" }, "scripts": { "watch": "gulp watch", diff --git a/package.json b/package.json index 0682a6b63fa4..77b8f4469aa6 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "chrome-debug": "./lighthouse-cli/manual-chrome-launcher.js" }, "engines": { - "node": ">=5" + "node": ">=6" }, "scripts": { "install-all": "npm run install-cli && npm run install-extension && npm run install-viewer", @@ -21,7 +21,7 @@ "build-viewer": "npm run build -C ./lighthouse-viewer", "lint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .", "smoke": "lighthouse-cli/test/smokehouse/offline-local/run-tests.sh && lighthouse-cli/test/smokehouse/dobetterweb/run-tests.sh", - "coverage": "node $__node_harmony $(npm bin)/istanbul cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*-test.js') --timeout 10000 --reporter progress", + "coverage": "node $(npm bin)/istanbul cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*-test.js') --timeout 10000 --reporter progress", "coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls", "start": "node ./lighthouse-cli/index.js", "test": "npm run lint --silent && npm run unit", @@ -33,7 +33,7 @@ "watch": "lighthouse-core/scripts/run-mocha.sh --watch", "chrome": "./lighthouse-cli/manual-chrome-launcher.js", "fast": "npm run start -- --disable-device-emulation --disable-cpu-throttling --disable-network-throttling", - "smokehouse": "node $__node_harmony lighthouse-cli/test/smokehouse/smokehouse.js", + "smokehouse": "node lighthouse-cli/test/smokehouse/smokehouse.js", "deploy-viewer": "cd lighthouse-viewer && gulp deploy" }, "devDependencies": { diff --git a/readme.md b/readme.md index 52914ecf1457..6c1b5a619995 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,7 @@ Quick-start guide on using the Lighthouse extension: http://bit.ly/lighthouse-qu ## Install CLI [![NPM lighthouse package](https://img.shields.io/npm/v/lighthouse.svg)](https://npmjs.org/package/lighthouse) -Requires Node v5+ or Node v4 w/ `--harmony` +Requires Node v6+ ```sh npm install -g lighthouse