Merge pull request #4109 from atom/const
[WIP] Use `const` for requires
This commit is contained in:
commit
3875b30fcf
44 changed files with 314 additions and 437 deletions
|
@ -1,18 +1,11 @@
|
|||
var CrashReporter, binding, crashRepoter, electron, fs, os, path, spawn;
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const spawn = require('child_process').spawn;
|
||||
const electron = require('electron');
|
||||
const binding = process.atomBinding('crash_reporter');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
os = require('os');
|
||||
|
||||
path = require('path');
|
||||
|
||||
spawn = require('child_process').spawn;
|
||||
|
||||
electron = require('electron');
|
||||
|
||||
binding = process.atomBinding('crash_reporter');
|
||||
|
||||
CrashReporter = (function() {
|
||||
var CrashReporter = (function() {
|
||||
function CrashReporter() {}
|
||||
|
||||
CrashReporter.prototype.start = function(options) {
|
||||
|
@ -99,6 +92,4 @@ CrashReporter = (function() {
|
|||
|
||||
})();
|
||||
|
||||
crashRepoter = new CrashReporter;
|
||||
|
||||
module.exports = crashRepoter;
|
||||
module.exports = new CrashReporter;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Do not expose the internal modules to `require`.
|
||||
exports.hideInternalModules = function() {
|
||||
var globalPaths;
|
||||
globalPaths = require('module').globalPaths;
|
||||
var globalPaths = require('module').globalPaths;
|
||||
if (globalPaths.length === 3) {
|
||||
|
||||
// Remove the "common/api/lib" and "browser-or-renderer/api/lib".
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var deprecate, nativeImage;
|
||||
|
||||
deprecate = require('electron').deprecate;
|
||||
|
||||
nativeImage = process.atomBinding('native_image');
|
||||
const deprecate = require('electron').deprecate;
|
||||
const nativeImage = process.atomBinding('native_image');
|
||||
|
||||
// Deprecated.
|
||||
deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL');
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
(function () {
|
||||
var asar, asarStatsToFsStats, cachedArchives, child_process, fakeTime, getOrCreateArchive, gid, invalidArchiveError, nextInode, notDirError, notFoundError, overrideAPI, overrideAPISync, path, splitPath, uid, util,
|
||||
hasProp = {}.hasOwnProperty;
|
||||
const asar = process.binding('atom_common_asar');
|
||||
const child_process = require('child_process');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
|
||||
asar = process.binding('atom_common_asar');
|
||||
|
||||
child_process = require('child_process');
|
||||
|
||||
path = require('path');
|
||||
|
||||
util = require('util');
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
|
||||
// Cache asar archive objects.
|
||||
cachedArchives = {};
|
||||
var cachedArchives = {};
|
||||
|
||||
getOrCreateArchive = function(p) {
|
||||
var getOrCreateArchive = function(p) {
|
||||
var archive;
|
||||
archive = cachedArchives[p];
|
||||
if (archive != null) {
|
||||
|
@ -39,13 +35,14 @@ process.on('exit', function() {
|
|||
});
|
||||
|
||||
// Separate asar package's path from full path.
|
||||
splitPath = function(p) {
|
||||
var splitPath = function(p) {
|
||||
var index;
|
||||
|
||||
// shortcut to disable asar.
|
||||
var index;
|
||||
if (process.noAsar) {
|
||||
return [false];
|
||||
}
|
||||
|
||||
if (typeof p !== 'string') {
|
||||
return [false];
|
||||
}
|
||||
|
@ -61,15 +58,15 @@ splitPath = function(p) {
|
|||
};
|
||||
|
||||
// Convert asar archive's Stats object to fs's Stats object.
|
||||
nextInode = 0;
|
||||
var nextInode = 0;
|
||||
|
||||
uid = process.getuid != null ? process.getuid() : 0;
|
||||
var uid = process.getuid != null ? process.getuid() : 0;
|
||||
|
||||
gid = process.getgid != null ? process.getgid() : 0;
|
||||
var gid = process.getgid != null ? process.getgid() : 0;
|
||||
|
||||
fakeTime = new Date();
|
||||
var fakeTime = new Date();
|
||||
|
||||
asarStatsToFsStats = function(stats) {
|
||||
var asarStatsToFsStats = function(stats) {
|
||||
return {
|
||||
dev: 1,
|
||||
ino: ++nextInode,
|
||||
|
@ -108,7 +105,7 @@ asarStatsToFsStats = function(stats) {
|
|||
};
|
||||
|
||||
// Create a ENOENT error.
|
||||
notFoundError = function(asarPath, filePath, callback) {
|
||||
var notFoundError = function(asarPath, filePath, callback) {
|
||||
var error;
|
||||
error = new Error("ENOENT, " + filePath + " not found in " + asarPath);
|
||||
error.code = "ENOENT";
|
||||
|
@ -122,7 +119,7 @@ notFoundError = function(asarPath, filePath, callback) {
|
|||
};
|
||||
|
||||
// Create a ENOTDIR error.
|
||||
notDirError = function(callback) {
|
||||
var notDirError = function(callback) {
|
||||
var error;
|
||||
error = new Error('ENOTDIR, not a directory');
|
||||
error.code = 'ENOTDIR';
|
||||
|
@ -136,7 +133,7 @@ notDirError = function(callback) {
|
|||
};
|
||||
|
||||
// Create invalid archive error.
|
||||
invalidArchiveError = function(asarPath, callback) {
|
||||
var invalidArchiveError = function(asarPath, callback) {
|
||||
var error;
|
||||
error = new Error("Invalid package " + asarPath);
|
||||
if (typeof callback !== 'function') {
|
||||
|
@ -148,7 +145,7 @@ invalidArchiveError = function(asarPath, callback) {
|
|||
};
|
||||
|
||||
// Override APIs that rely on passing file path instead of content to C++.
|
||||
overrideAPISync = function(module, name, arg) {
|
||||
var overrideAPISync = function(module, name, arg) {
|
||||
var old;
|
||||
if (arg == null) {
|
||||
arg = 0;
|
||||
|
@ -174,7 +171,7 @@ overrideAPISync = function(module, name, arg) {
|
|||
};
|
||||
};
|
||||
|
||||
overrideAPI = function(module, name, arg) {
|
||||
var overrideAPI = function(module, name, arg) {
|
||||
var old;
|
||||
if (arg == null) {
|
||||
arg = 0;
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
var Module, fs, path, timers, wrapWithActivateUvLoop;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
path = require('path');
|
||||
|
||||
timers = require('timers');
|
||||
|
||||
Module = require('module');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const timers = require('timers');
|
||||
const Module = require('module');
|
||||
|
||||
process.atomBinding = function(name) {
|
||||
var e, error;
|
||||
|
@ -32,7 +27,7 @@ if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
|
|||
// which would delay the callbacks for arbitrary long time. So we should
|
||||
// initiatively activate the uv loop once setImmediate and process.nextTick is
|
||||
// called.
|
||||
wrapWithActivateUvLoop = function(func) {
|
||||
var wrapWithActivateUvLoop = function(func) {
|
||||
return function() {
|
||||
process.activateUvLoop();
|
||||
return func.apply(this, arguments);
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var Module, path;
|
||||
|
||||
path = require('path');
|
||||
|
||||
Module = require('module');
|
||||
const path = require('path');
|
||||
const Module = require('module');
|
||||
|
||||
// Clear Node's global search paths.
|
||||
Module.globalPaths.length = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue