🎨
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.
|
||||
module.paths = []
|
||||
|
||||
module.parent.paths = []
|
||||
|
||||
// Prevent Node from adding paths outside this app to search paths.
|
||||
Module._nodeModulePaths = function (from) {
|
||||
var dir, i, part, parts, paths, skipOutsidePaths, splitRe, tip
|
||||
from = path.resolve(from)
|
||||
|
||||
// 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.
|
||||
splitRe = process.platform === 'win32' ? /[\/\\]/ : /\//
|
||||
paths = []
|
||||
parts = from.split(splitRe)
|
||||
for (tip = i = parts.length - 1; i >= 0; tip = i += -1) {
|
||||
part = parts[tip]
|
||||
const splitRe = process.platform === 'win32' ? /[\/\\]/ : /\//
|
||||
const paths = []
|
||||
const parts = from.split(splitRe)
|
||||
|
||||
for (let tip = i = parts.length - 1; i >= 0; tip = i += -1) {
|
||||
const part = parts[tip]
|
||||
if (part === 'node_modules') {
|
||||
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)) {
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue