Use destructuring assigment
This commit is contained in:
parent
baa566adae
commit
4f4dc2f4d8
3 changed files with 40 additions and 48 deletions
|
@ -150,9 +150,9 @@
|
|||
}
|
||||
old = module[name];
|
||||
return module[name] = function() {
|
||||
var archive, asarPath, filePath, isAsar, newPath, p, ref;
|
||||
var archive, newPath, p;
|
||||
p = arguments[arg];
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return old.apply(this, arguments);
|
||||
}
|
||||
|
@ -176,9 +176,9 @@
|
|||
}
|
||||
old = module[name];
|
||||
return module[name] = function() {
|
||||
var archive, asarPath, callback, filePath, isAsar, newPath, p, ref;
|
||||
var archive, callback, newPath, p;
|
||||
p = arguments[arg];
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return old.apply(this, arguments);
|
||||
}
|
||||
|
@ -221,8 +221,8 @@
|
|||
|
||||
lstatSync = fs.lstatSync;
|
||||
fs.lstatSync = function(p) {
|
||||
var archive, asarPath, filePath, isAsar, ref, stats;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, stats;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return lstatSync(p);
|
||||
}
|
||||
|
@ -238,8 +238,8 @@
|
|||
};
|
||||
lstat = fs.lstat;
|
||||
fs.lstat = function(p, callback) {
|
||||
var archive, asarPath, filePath, isAsar, ref, stats;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, stats;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return lstat(p, callback);
|
||||
}
|
||||
|
@ -257,7 +257,7 @@
|
|||
};
|
||||
statSync = fs.statSync;
|
||||
fs.statSync = function(p) {
|
||||
var isAsar = splitPath(p)[0];
|
||||
const [isAsar] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return statSync(p);
|
||||
}
|
||||
|
@ -267,7 +267,7 @@
|
|||
};
|
||||
stat = fs.stat;
|
||||
fs.stat = function(p, callback) {
|
||||
var isAsar = splitPath(p)[0];
|
||||
const [isAsar] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return stat(p, callback);
|
||||
}
|
||||
|
@ -279,8 +279,8 @@
|
|||
};
|
||||
statSyncNoException = fs.statSyncNoException;
|
||||
fs.statSyncNoException = function(p) {
|
||||
var archive, asarPath, filePath, isAsar, ref, stats;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, stats;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return statSyncNoException(p);
|
||||
}
|
||||
|
@ -296,8 +296,8 @@
|
|||
};
|
||||
realpathSync = fs.realpathSync;
|
||||
fs.realpathSync = function(p) {
|
||||
var archive, asarPath, filePath, isAsar, real, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, real;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return realpathSync.apply(this, arguments);
|
||||
}
|
||||
|
@ -313,8 +313,8 @@
|
|||
};
|
||||
realpath = fs.realpath;
|
||||
fs.realpath = function(p, cache, callback) {
|
||||
var archive, asarPath, filePath, isAsar, real, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, real;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return realpath.apply(this, arguments);
|
||||
}
|
||||
|
@ -339,8 +339,8 @@
|
|||
};
|
||||
exists = fs.exists;
|
||||
fs.exists = function(p, callback) {
|
||||
var archive, asarPath, filePath, isAsar, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return exists(p, callback);
|
||||
}
|
||||
|
@ -354,8 +354,8 @@
|
|||
};
|
||||
existsSync = fs.existsSync;
|
||||
fs.existsSync = function(p) {
|
||||
var archive, asarPath, filePath, isAsar, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return existsSync(p);
|
||||
}
|
||||
|
@ -367,8 +367,8 @@
|
|||
};
|
||||
readFile = fs.readFile;
|
||||
fs.readFile = function(p, options, callback) {
|
||||
var archive, asarPath, buffer, encoding, fd, filePath, info, isAsar, realPath, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, buffer, encoding, fd, info, realPath;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return readFile.apply(this, arguments);
|
||||
}
|
||||
|
@ -418,9 +418,9 @@
|
|||
readFileSync = fs.readFileSync;
|
||||
fs.readFileSync = function(p, opts) {
|
||||
// this allows v8 to optimize this function
|
||||
var archive, asarPath, buffer, encoding, fd, filePath, info, isAsar, options, realPath, ref;
|
||||
var archive, buffer, encoding, fd, info, options, realPath;
|
||||
options = opts;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return readFileSync.apply(this, arguments);
|
||||
}
|
||||
|
@ -470,8 +470,8 @@
|
|||
};
|
||||
readdir = fs.readdir;
|
||||
fs.readdir = function(p, callback) {
|
||||
var archive, asarPath, filePath, files, isAsar, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, files;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return readdir.apply(this, arguments);
|
||||
}
|
||||
|
@ -489,8 +489,8 @@
|
|||
};
|
||||
readdirSync = fs.readdirSync;
|
||||
fs.readdirSync = function(p) {
|
||||
var archive, asarPath, filePath, files, isAsar, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, files;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return readdirSync.apply(this, arguments);
|
||||
}
|
||||
|
@ -506,8 +506,8 @@
|
|||
};
|
||||
internalModuleReadFile = process.binding('fs').internalModuleReadFile;
|
||||
process.binding('fs').internalModuleReadFile = function(p) {
|
||||
var archive, asarPath, buffer, fd, filePath, info, isAsar, realPath, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, buffer, fd, info, realPath;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return internalModuleReadFile(p);
|
||||
}
|
||||
|
@ -539,8 +539,8 @@
|
|||
};
|
||||
internalModuleStat = process.binding('fs').internalModuleStat;
|
||||
process.binding('fs').internalModuleStat = function(p) {
|
||||
var archive, asarPath, filePath, isAsar, ref, stats;
|
||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
||||
var archive, stats;
|
||||
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||
if (!isAsar) {
|
||||
return internalModuleStat(p);
|
||||
}
|
||||
|
@ -570,11 +570,10 @@
|
|||
if (process.platform === 'win32') {
|
||||
mkdir = fs.mkdir;
|
||||
fs.mkdir = function(p, mode, callback) {
|
||||
var filePath, isAsar, ref;
|
||||
if (typeof mode === 'function') {
|
||||
callback = mode;
|
||||
}
|
||||
ref = splitPath(p), isAsar = ref[0], filePath = ref[2];
|
||||
const [isAsar, , filePath] = splitPath(p);
|
||||
if (isAsar && filePath.length) {
|
||||
return notDirError(callback);
|
||||
}
|
||||
|
@ -582,8 +581,7 @@
|
|||
};
|
||||
mkdirSync = fs.mkdirSync;
|
||||
fs.mkdirSync = function(p, mode) {
|
||||
var filePath, isAsar, ref;
|
||||
ref = splitPath(p), isAsar = ref[0], filePath = ref[2];
|
||||
const [isAsar, , filePath] = splitPath(p);
|
||||
if (isAsar && filePath.length) {
|
||||
notDirError();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue