From 5d647bf1fafc4187a527154949a87557799d5087 Mon Sep 17 00:00:00 2001 From: JoelEinbinder Date: Wed, 2 Aug 2017 12:06:47 -0700 Subject: [PATCH] Use const a lot fo places (#188) --- install.js | 6 +++--- lib/Browser.js | 22 +++++++++++----------- lib/Connection.js | 8 ++++---- lib/FrameManager.js | 8 ++++---- lib/Page.js | 22 +++++++++++----------- phantom_shim/FileSystem.js | 10 +++++----- phantom_shim/Phantom.js | 8 ++++---- phantom_shim/System.js | 6 +++--- phantom_shim/WebPage.js | 12 ++++++------ phantom_shim/WebServer.js | 4 ++-- phantom_shim/runner.js | 22 +++++++++++----------- phantom_shim/utilities.js | 2 +- test/golden-utils.js | 12 ++++++------ test/server/SimpleServer.js | 14 +++++++------- test/test.js | 28 ++++++++++++++-------------- utils/ChromiumDownloader.js | 20 ++++++++++---------- utils/check_availability.js | 8 ++++---- 17 files changed, 106 insertions(+), 106 deletions(-) diff --git a/install.js b/install.js index 35ef43e009e..cf506838436 100644 --- a/install.js +++ b/install.js @@ -14,9 +14,9 @@ * limitations under the License. */ -let Downloader = require('./utils/ChromiumDownloader'); -let revision = require('./package').puppeteer.chromium_revision; -let ProgressBar = require('progress'); +const Downloader = require('./utils/ChromiumDownloader'); +const revision = require('./package').puppeteer.chromium_revision; +const ProgressBar = require('progress'); // Do nothing if the revision is already downloaded. if (Downloader.revisionInfo(Downloader.currentPlatform(), revision)) diff --git a/lib/Browser.js b/lib/Browser.js index f4fd7919cc5..40f414c0c19 100644 --- a/lib/Browser.js +++ b/lib/Browser.js @@ -14,20 +14,20 @@ * limitations under the License. */ -let {Duplex} = require('stream'); -let path = require('path'); -let helper = require('./helper'); -let removeRecursive = require('rimraf').sync; -let Page = require('./Page'); -let childProcess = require('child_process'); -let Downloader = require('../utils/ChromiumDownloader'); -let Connection = require('./Connection'); -let readline = require('readline'); +const {Duplex} = require('stream'); +const path = require('path'); +const helper = require('./helper'); +const removeRecursive = require('rimraf').sync; +const Page = require('./Page'); +const childProcess = require('child_process'); +const Downloader = require('../utils/ChromiumDownloader'); +const Connection = require('./Connection'); +const readline = require('readline'); -let CHROME_PROFILE_PATH = path.resolve(__dirname, '..', '.dev_profile'); +const CHROME_PROFILE_PATH = path.resolve(__dirname, '..', '.dev_profile'); let browserId = 0; -let DEFAULT_ARGS = [ +const DEFAULT_ARGS = [ '--disable-background-networking', '--disable-background-timer-throttling', '--disable-client-side-phishing-detection', diff --git a/lib/Connection.js b/lib/Connection.js index a38c32099f8..b1e1d4694aa 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let debug = require('debug')('puppeteer:protocol'); +const debug = require('debug')('puppeteer:protocol'); -let EventEmitter = require('events'); -let WebSocket = require('ws'); -let http = require('http'); +const EventEmitter = require('events'); +const WebSocket = require('ws'); +const http = require('http'); const COMMAND_TIMEOUT = 10000; class Connection extends EventEmitter { diff --git a/lib/FrameManager.js b/lib/FrameManager.js index 2e2830cb43f..c126ba56491 100644 --- a/lib/FrameManager.js +++ b/lib/FrameManager.js @@ -14,10 +14,10 @@ * limitations under the License. */ -let fs = require('fs'); -let path = require('path'); -let EventEmitter = require('events'); -let helper = require('./helper'); +const fs = require('fs'); +const path = require('path'); +const EventEmitter = require('events'); +const helper = require('./helper'); class FrameManager extends EventEmitter { /** diff --git a/lib/Page.js b/lib/Page.js index e344f4ea425..f12c679517c 100644 --- a/lib/Page.js +++ b/lib/Page.js @@ -14,17 +14,17 @@ * limitations under the License. */ -let fs = require('fs'); -let EventEmitter = require('events'); -let mime = require('mime'); -let NetworkManager = require('./NetworkManager'); -let NavigatorWatcher = require('./NavigatorWatcher'); -let Dialog = require('./Dialog'); -let EmulationManager = require('./EmulationManager'); -let FrameManager = require('./FrameManager'); -let {Keyboard, Mouse} = require('./Input'); -let Tracing = require('./Tracing'); -let helper = require('./helper'); +const fs = require('fs'); +const EventEmitter = require('events'); +const mime = require('mime'); +const NetworkManager = require('./NetworkManager'); +const NavigatorWatcher = require('./NavigatorWatcher'); +const Dialog = require('./Dialog'); +const EmulationManager = require('./EmulationManager'); +const FrameManager = require('./FrameManager'); +const {Keyboard, Mouse} = require('./Input'); +const Tracing = require('./Tracing'); +const helper = require('./helper'); class Page extends EventEmitter { /** diff --git a/phantom_shim/FileSystem.js b/phantom_shim/FileSystem.js index 30ec4888fa3..7530a3d3238 100644 --- a/phantom_shim/FileSystem.js +++ b/phantom_shim/FileSystem.js @@ -14,11 +14,11 @@ * limitations under the License. */ -let path = require('path'); -let fs = require('fs'); -let deasync = require('deasync'); -let removeRecursive = require('rimraf').sync; -let copyRecursive = deasync(require('ncp').ncp); +const path = require('path'); +const fs = require('fs'); +const deasync = require('deasync'); +const removeRecursive = require('rimraf').sync; +const copyRecursive = deasync(require('ncp').ncp); class FileSystem { constructor() { diff --git a/phantom_shim/Phantom.js b/phantom_shim/Phantom.js index 3809233cd05..30d3dccfcca 100644 --- a/phantom_shim/Phantom.js +++ b/phantom_shim/Phantom.js @@ -14,10 +14,10 @@ * limitations under the License. */ -let fs = require('fs'); -let path = require('path'); -let vm = require('vm'); -let url = require('url'); +const fs = require('fs'); +const path = require('path'); +const vm = require('vm'); +const url = require('url'); const VERSION = [0, 0, 1]; diff --git a/phantom_shim/System.js b/phantom_shim/System.js index 06286e2e0c0..e384af5c475 100644 --- a/phantom_shim/System.js +++ b/phantom_shim/System.js @@ -14,9 +14,9 @@ * limitations under the License. */ -let readline = require('readline'); -let await = require('./utilities').await; -let os = require('os'); +const readline = require('readline'); +const await = require('./utilities').await; +const os = require('os'); class System { /** diff --git a/phantom_shim/WebPage.js b/phantom_shim/WebPage.js index 82f650ac2bf..51da61e0c0c 100644 --- a/phantom_shim/WebPage.js +++ b/phantom_shim/WebPage.js @@ -14,13 +14,13 @@ * limitations under the License. */ -let await = require('./utilities').await; -let EventEmitter = require('events'); -let fs = require('fs'); -let path = require('path'); -let PageEvents = require('../lib/Page').Events; +const await = require('./utilities').await; +const EventEmitter = require('events'); +const fs = require('fs'); +const path = require('path'); +const PageEvents = require('../lib/Page').Events; -let noop = function() { }; +const noop = function() { }; class WebPage { /** diff --git a/phantom_shim/WebServer.js b/phantom_shim/WebServer.js index 05c3168ca9b..61eab2c7d0b 100644 --- a/phantom_shim/WebServer.js +++ b/phantom_shim/WebServer.js @@ -14,8 +14,8 @@ * limitations under the License. */ -let http = require('http'); -let await = require('./utilities').await; +const http = require('http'); +const await = require('./utilities').await; class WebServer { constructor() { diff --git a/phantom_shim/runner.js b/phantom_shim/runner.js index 2e1195b9276..0a2ea3d7d05 100755 --- a/phantom_shim/runner.js +++ b/phantom_shim/runner.js @@ -15,17 +15,17 @@ * limitations under the License. */ -let vm = require('vm'); -let path = require('path'); -let fs = require('fs'); -let Phantom = require('./Phantom'); -let FileSystem = require('./FileSystem'); -let System = require('./System'); -let WebPage = require('./WebPage'); -let WebServer = require('./WebServer'); -let child_process = require('child_process'); -let Browser = require('..').Browser; -let argv = require('minimist')(process.argv.slice(2), { +const vm = require('vm'); +const path = require('path'); +const fs = require('fs'); +const Phantom = require('./Phantom'); +const FileSystem = require('./FileSystem'); +const System = require('./System'); +const WebPage = require('./WebPage'); +const WebServer = require('./WebServer'); +const child_process = require('child_process'); +const Browser = require('..').Browser; +const argv = require('minimist')(process.argv.slice(2), { alias: { v: 'version' }, boolean: ['headless'], default: {'headless': true }, diff --git a/phantom_shim/utilities.js b/phantom_shim/utilities.js index 3f6c7453bc0..1f36ac94be7 100644 --- a/phantom_shim/utilities.js +++ b/phantom_shim/utilities.js @@ -14,7 +14,7 @@ * limitations under the License. */ -let loopWhile = require('deasync').loopWhile; +const loopWhile = require('deasync').loopWhile; module.exports = { await: function(promise) { diff --git a/test/golden-utils.js b/test/golden-utils.js index 7b86eeab8f2..ad428c1cd3e 100644 --- a/test/golden-utils.js +++ b/test/golden-utils.js @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let path = require('path'); -let fs = require('fs'); -let Diff = require('text-diff'); -let mime = require('mime'); -let PNG = require('pngjs').PNG; -let pixelmatch = require('pixelmatch'); +const path = require('path'); +const fs = require('fs'); +const Diff = require('text-diff'); +const mime = require('mime'); +const PNG = require('pngjs').PNG; +const pixelmatch = require('pixelmatch'); module.exports = { addMatchers: function(jasmine, goldenPath, outputPath) { diff --git a/test/server/SimpleServer.js b/test/server/SimpleServer.js index 3ba3ec7f5ba..5c4917c6078 100644 --- a/test/server/SimpleServer.js +++ b/test/server/SimpleServer.js @@ -14,13 +14,13 @@ * limitations under the License. */ -let http = require('http'); -let https = require('https'); -let url = require('url'); -let fs = require('fs'); -let path = require('path'); -let mime = require('mime'); -let WebSocketServer = require('ws').Server; +const http = require('http'); +const https = require('https'); +const url = require('url'); +const fs = require('fs'); +const path = require('path'); +const mime = require('mime'); +const WebSocketServer = require('ws').Server; const fulfillSymbol = Symbol('fullfill callback'); const rejectSymbol = Symbol('reject callback'); diff --git a/test/test.js b/test/test.js index 17764c00dfb..47508b2df13 100644 --- a/test/test.js +++ b/test/test.js @@ -14,24 +14,24 @@ * limitations under the License. */ -let fs = require('fs'); -let rm = require('rimraf').sync; -let path = require('path'); -let helper = require('../lib/helper'); +const fs = require('fs'); +const rm = require('rimraf').sync; +const path = require('path'); +const helper = require('../lib/helper'); if (process.env.COVERAGE) helper.recordPublicAPICoverage(); -let Browser = require('../lib/Browser'); -let SimpleServer = require('./server/SimpleServer'); -let GoldenUtils = require('./golden-utils'); +const Browser = require('../lib/Browser'); +const SimpleServer = require('./server/SimpleServer'); +const GoldenUtils = require('./golden-utils'); -let GOLDEN_DIR = path.join(__dirname, 'golden'); -let OUTPUT_DIR = path.join(__dirname, 'output'); +const GOLDEN_DIR = path.join(__dirname, 'golden'); +const OUTPUT_DIR = path.join(__dirname, 'output'); -let PORT = 8907; -let PREFIX = 'http://localhost:' + PORT; -let EMPTY_PAGE = PREFIX + '/empty.html'; -let HTTPS_PORT = 8908; -let HTTPS_PREFIX = 'https://localhost:' + HTTPS_PORT; +const PORT = 8907; +const PREFIX = 'http://localhost:' + PORT; +const EMPTY_PAGE = PREFIX + '/empty.html'; +const HTTPS_PORT = 8908; +const HTTPS_PREFIX = 'https://localhost:' + HTTPS_PORT; const iPhone = require('../DeviceDescriptors')['iPhone 6']; const iPhoneLandscape = require('../DeviceDescriptors')['iPhone 6 landscape']; diff --git a/utils/ChromiumDownloader.js b/utils/ChromiumDownloader.js index 6b5ecc7fd2f..6653f63ffd7 100644 --- a/utils/ChromiumDownloader.js +++ b/utils/ChromiumDownloader.js @@ -14,18 +14,18 @@ * limitations under the License. */ -let os = require('os'); -let https = require('https'); -let fs = require('fs'); -let path = require('path'); -let extract = require('extract-zip'); -let util = require('util'); -let URL = require('url'); -let removeRecursive = require('rimraf'); +const os = require('os'); +const https = require('https'); +const fs = require('fs'); +const path = require('path'); +const extract = require('extract-zip'); +const util = require('util'); +const URL = require('url'); +const removeRecursive = require('rimraf'); -let DOWNLOADS_FOLDER = path.join(__dirname, '..', '.local-chromium'); +const DOWNLOADS_FOLDER = path.join(__dirname, '..', '.local-chromium'); -let downloadURLs = { +const downloadURLs = { linux: 'https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/%d/chrome-linux.zip', mac: 'https://storage.googleapis.com/chromium-browser-snapshots/Mac/%d/chrome-mac.zip', win32: 'https://storage.googleapis.com/chromium-browser-snapshots/Win/%d/chrome-win32.zip', diff --git a/utils/check_availability.js b/utils/check_availability.js index 9f5614a3ed6..25c9949f140 100755 --- a/utils/check_availability.js +++ b/utils/check_availability.js @@ -15,11 +15,11 @@ * limitations under the License. */ -let Downloader = require('./ChromiumDownloader'); -let https = require('https'); -let OMAHA_PROXY = 'https://omahaproxy.appspot.com/all.json'; +const Downloader = require('./ChromiumDownloader'); +const https = require('https'); +const OMAHA_PROXY = 'https://omahaproxy.appspot.com/all.json'; -let colors = { +const colors = { reset: '\x1b[0m', red: '\x1b[31m', green: '\x1b[32m',