From 9103253f62208f52d556a4738ec9d9c47a1830e6 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 14 Jan 2016 13:16:42 -0800 Subject: [PATCH] Use `const` --- atom/browser/api/lib/app.js | 24 +++++++++------ atom/browser/api/lib/auto-updater.js | 7 ++--- .../lib/auto-updater/auto-updater-native.js | 7 ++--- .../api/lib/auto-updater/auto-updater-win.js | 18 +++++------- .../lib/auto-updater/squirrel-update-win.js | 18 +++++------- atom/browser/api/lib/browser-window.js | 11 +++---- atom/browser/api/lib/dialog.js | 29 +++++++++---------- atom/browser/api/lib/exports/electron.js | 4 +-- atom/browser/api/lib/ipc-main.js | 4 +-- atom/browser/api/lib/ipc.js | 5 ++-- 10 files changed, 55 insertions(+), 72 deletions(-) diff --git a/atom/browser/api/lib/app.js b/atom/browser/api/lib/app.js index 560fcb8630ee..bd820127cd9a 100644 --- a/atom/browser/api/lib/app.js +++ b/atom/browser/api/lib/app.js @@ -1,15 +1,21 @@ -var EventEmitter, Menu, app, appPath, bindings, deprecate, downloadItemBindings, fn, i, len, name, ref, ref1, session, wrapDownloadItem, - slice = [].slice; +const deprecate = require('electron').deprecate; +const session = require('electron').session; +const Menu = require('electron').Menu; +const EventEmitter = require('events').EventEmitter; -ref = require('electron'), deprecate = ref.deprecate, session = ref.session, Menu = ref.Menu; +const bindings = process.atomBinding('app'); +const downloadItemBindings = process.atomBinding('download_item'); +const app = bindings.app; -EventEmitter = require('events').EventEmitter; +var slice = [].slice; -bindings = process.atomBinding('app'); - -downloadItemBindings = process.atomBinding('download_item'); - -app = bindings.app; +var appPath; +var fn; +var i; +var len; +var name; +var ref1; +var wrapDownloadItem; app.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/auto-updater.js b/atom/browser/api/lib/auto-updater.js index a3ffc12e9f2d..9cc1fada0675 100644 --- a/atom/browser/api/lib/auto-updater.js +++ b/atom/browser/api/lib/auto-updater.js @@ -1,8 +1,5 @@ -var autoUpdater, deprecate; - -deprecate = require('electron').deprecate; - -autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native'); +const deprecate = require('electron').deprecate; +const autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native'); // Deprecated. deprecate.rename(autoUpdater, 'setFeedUrl', 'setFeedURL'); diff --git a/atom/browser/api/lib/auto-updater/auto-updater-native.js b/atom/browser/api/lib/auto-updater/auto-updater-native.js index 9f22b33feb1d..20c69cdb5a2b 100644 --- a/atom/browser/api/lib/auto-updater/auto-updater-native.js +++ b/atom/browser/api/lib/auto-updater/auto-updater-native.js @@ -1,8 +1,5 @@ -var EventEmitter, autoUpdater; - -EventEmitter = require('events').EventEmitter; - -autoUpdater = process.atomBinding('auto_updater').autoUpdater; +const EventEmitter = require('events').EventEmitter; +const autoUpdater = process.atomBinding('auto_updater').autoUpdater; autoUpdater.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/auto-updater/auto-updater-win.js b/atom/browser/api/lib/auto-updater/auto-updater-win.js index 61b1911e232e..bbe02555a0b8 100644 --- a/atom/browser/api/lib/auto-updater/auto-updater-win.js +++ b/atom/browser/api/lib/auto-updater/auto-updater-win.js @@ -1,16 +1,12 @@ -var AutoUpdater, EventEmitter, app, squirrelUpdate, url, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; +const app = require('electron').app; +const EventEmitter = require('events').EventEmitter; +const url = require('url'); +const squirrelUpdate = require('./squirrel-update-win'); -app = require('electron').app; +var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, +hasProp = {}.hasOwnProperty; -EventEmitter = require('events').EventEmitter; - -url = require('url'); - -squirrelUpdate = require('./squirrel-update-win'); - -AutoUpdater = (function(superClass) { +var AutoUpdater = (function(superClass) { extend(AutoUpdater, superClass); function AutoUpdater() { diff --git a/atom/browser/api/lib/auto-updater/squirrel-update-win.js b/atom/browser/api/lib/auto-updater/squirrel-update-win.js index 49d525f4a684..8fe8a3786db9 100644 --- a/atom/browser/api/lib/auto-updater/squirrel-update-win.js +++ b/atom/browser/api/lib/auto-updater/squirrel-update-win.js @@ -1,22 +1,18 @@ -var appFolder, exeName, fs, path, spawn, spawnUpdate, updateExe; - -fs = require('fs'); - -path = require('path'); - -spawn = require('child_process').spawn; +const fs = require('fs'); +const path = require('path'); +const spawn = require('child_process').spawn; // i.e. my-app/app-0.1.13/ -appFolder = path.dirname(process.execPath); +const appFolder = path.dirname(process.execPath); // i.e. my-app/Update.exe -updateExe = path.resolve(appFolder, '..', 'Update.exe'); +const updateExe = path.resolve(appFolder, '..', 'Update.exe'); -exeName = path.basename(process.execPath); +const exeName = path.basename(process.execPath); // Spawn a command and invoke the callback when it completes with an error // and the output from standard out. -spawnUpdate = function(args, detached, callback) { +var spawnUpdate = function(args, detached, callback) { var error, error1, errorEmitted, spawnedProcess, stderr, stdout; try { spawnedProcess = spawn(updateExe, args, { diff --git a/atom/browser/api/lib/browser-window.js b/atom/browser/api/lib/browser-window.js index df9ae1647383..1268b0f80127 100644 --- a/atom/browser/api/lib/browser-window.js +++ b/atom/browser/api/lib/browser-window.js @@ -1,10 +1,7 @@ -var BrowserWindow, EventEmitter, deprecate, ipcMain, ref; - -ref = require('electron'), ipcMain = ref.ipcMain, deprecate = ref.deprecate; - -EventEmitter = require('events').EventEmitter; - -BrowserWindow = process.atomBinding('window').BrowserWindow; +const ipcMain = require('electron').ipcMain; +const deprecate = require('electron').deprecate; +const EventEmitter = require('events').EventEmitter; +const BrowserWindow = process.atomBinding('window').BrowserWindow; BrowserWindow.prototype.__proto__ = EventEmitter.prototype; diff --git a/atom/browser/api/lib/dialog.js b/atom/browser/api/lib/dialog.js index 9ed49738a55b..302fa7bf07fe 100644 --- a/atom/browser/api/lib/dialog.js +++ b/atom/browser/api/lib/dialog.js @@ -1,27 +1,25 @@ -var BrowserWindow, api, app, binding, checkAppInitialized, fileDialogProperties, j, len, messageBoxOptions, messageBoxTypes, parseArgs, ref, ref1, v8Util, - slice = [].slice, - indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; +const app = require('electron').app; +const BrowserWindow = require('electron').BrowserWindow; +const binding = process.atomBinding('dialog'); +const v8Util = process.atomBinding('v8_util'); -ref = require('electron'), app = ref.app, BrowserWindow = ref.BrowserWindow; +var slice = [].slice; +var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; -binding = process.atomBinding('dialog'); - -v8Util = process.atomBinding('v8_util'); - -fileDialogProperties = { +var fileDialogProperties = { openFile: 1 << 0, openDirectory: 1 << 1, multiSelections: 1 << 2, createDirectory: 1 << 3 }; -messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']; +var messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']; -messageBoxOptions = { +var messageBoxOptions = { noLink: 1 << 0 }; -parseArgs = function(window, options, callback) { +var parseArgs = function(window, options, callback) { if (!(window === null || (window != null ? window.constructor : void 0) === BrowserWindow)) { // Shift. callback = options; @@ -36,7 +34,7 @@ parseArgs = function(window, options, callback) { return [window, options, callback]; }; -checkAppInitialized = function() { +var checkAppInitialized = function() { if (!app.isReady()) { throw new Error('dialog module can only be used after app is ready'); } @@ -164,8 +162,9 @@ module.exports = { }; // Mark standard asynchronous functions. -ref1 = ['showMessageBox', 'showOpenDialog', 'showSaveDialog']; +var ref1 = ['showMessageBox', 'showOpenDialog', 'showSaveDialog']; +var j, len for (j = 0, len = ref1.length; j < len; j++) { - api = ref1[j]; + var api = ref1[j]; v8Util.setHiddenValue(module.exports[api], 'asynchronous', true); } diff --git a/atom/browser/api/lib/exports/electron.js b/atom/browser/api/lib/exports/electron.js index 74ae751e0834..7f97fcdbc4cf 100644 --- a/atom/browser/api/lib/exports/electron.js +++ b/atom/browser/api/lib/exports/electron.js @@ -1,6 +1,4 @@ -var common; - -common = require('../../../../common/api/lib/exports/electron'); +const common = require('../../../../common/api/lib/exports/electron'); // Import common modules. diff --git a/atom/browser/api/lib/ipc-main.js b/atom/browser/api/lib/ipc-main.js index bd4300d2c244..e253e03eaabe 100644 --- a/atom/browser/api/lib/ipc-main.js +++ b/atom/browser/api/lib/ipc-main.js @@ -1,5 +1,3 @@ -var EventEmitter; - -EventEmitter = require('events').EventEmitter; +const EventEmitter = require('events').EventEmitter; module.exports = new EventEmitter; diff --git a/atom/browser/api/lib/ipc.js b/atom/browser/api/lib/ipc.js index ed20e976173f..6e9715154234 100644 --- a/atom/browser/api/lib/ipc.js +++ b/atom/browser/api/lib/ipc.js @@ -1,6 +1,5 @@ -var deprecate, ipcMain, ref; - -ref = require('electron'), deprecate = ref.deprecate, ipcMain = ref.ipcMain; +const deprecate = require('electron').deprecate; +const ipcMain = require('electron').ipcMain; // This module is deprecated, we mirror everything from ipcMain. deprecate.warn('ipc module', 'require("electron").ipcMain');