🎨
This commit is contained in:
parent
566b0676bc
commit
19fd841c30
1 changed files with 8 additions and 9 deletions
|
@ -6,27 +6,26 @@ Module.globalPaths.length = 0
|
||||||
|
|
||||||
// Clear current and parent(init.js)'s search paths.
|
// Clear current and parent(init.js)'s search paths.
|
||||||
module.paths = []
|
module.paths = []
|
||||||
|
|
||||||
module.parent.paths = []
|
module.parent.paths = []
|
||||||
|
|
||||||
// Prevent Node from adding paths outside this app to search paths.
|
// Prevent Node from adding paths outside this app to search paths.
|
||||||
Module._nodeModulePaths = function (from) {
|
Module._nodeModulePaths = function (from) {
|
||||||
var dir, i, part, parts, paths, skipOutsidePaths, splitRe, tip
|
|
||||||
from = path.resolve(from)
|
from = path.resolve(from)
|
||||||
|
|
||||||
// If "from" is outside the app then we do nothing.
|
// If "from" is outside the app then we do nothing.
|
||||||
skipOutsidePaths = from.startsWith(process.resourcesPath)
|
const skipOutsidePaths = from.startsWith(process.resourcesPath)
|
||||||
|
|
||||||
// Following logic is copied from module.js.
|
// Following logic is copied from module.js.
|
||||||
splitRe = process.platform === 'win32' ? /[\/\\]/ : /\//
|
const splitRe = process.platform === 'win32' ? /[\/\\]/ : /\//
|
||||||
paths = []
|
const paths = []
|
||||||
parts = from.split(splitRe)
|
const parts = from.split(splitRe)
|
||||||
for (tip = i = parts.length - 1; i >= 0; tip = i += -1) {
|
|
||||||
part = parts[tip]
|
for (let tip = i = parts.length - 1; i >= 0; tip = i += -1) {
|
||||||
|
const part = parts[tip]
|
||||||
if (part === 'node_modules') {
|
if (part === 'node_modules') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dir = parts.slice(0, tip + 1).join(path.sep)
|
const dir = parts.slice(0, tip + 1).join(path.sep)
|
||||||
if (skipOutsidePaths && !dir.startsWith(process.resourcesPath)) {
|
if (skipOutsidePaths && !dir.startsWith(process.resourcesPath)) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue