Avoid re-evaluating internal modules

This commit is contained in:
Cheng Zhao 2016-03-27 19:13:15 +09:00
Родитель 896ea7b79d
Коммит e5886dda9b
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -9,6 +9,12 @@
// Make graceful-fs work with asar.
var source = process.binding('natives');
source['original-fs'] = source.fs;
return source['fs'] = "var src = '(function (exports, require, module, __filename, __dirname) { ' +\n process.binding('natives')['original-fs'] +\n ' });';\nvar vm = require('vm');\nvar fn = vm.runInThisContext(src, { filename: 'fs.js' });\nfn(exports, require, module);\nvar asar = require('ATOM_SHELL_ASAR');\nasar.wrapFsWithAsar(exports);";
return source['fs'] = `
var nativeModule = new process.NativeModule('original-fs');
nativeModule.cache();
nativeModule.compile();
var asar = require('ATOM_SHELL_ASAR');
asar.wrapFsWithAsar(nativeModule.exports);
module.exports = nativeModule.exports`;
};
})();