fix a bug with internalModuleStat for 0.12.18

This commit is contained in:
Igor Klopov 2017-10-03 14:32:49 +03:00
parent f4705d99f4
commit f0e5ba30ef

View File

@ -201,7 +201,7 @@
--- node/src/node.js
+++ node/src/node.js
@@ -65,10 +65,52 @@
@@ -65,10 +65,50 @@
// There are various modes that Node can run in. The most common two
// are running from a script and running the REPL - but there are a few
// others like the debugger or running --eval arguments. Here we decide
@ -222,7 +222,7 @@
+ if (!PRELUDE_POSITION) {
+ // no prelude - remove entrypoint from argv[1]
+ process.argv.splice(1, 1);
+ return undefined;
+ return { undoPatch: true };
+ }
+ var prelude = new Buffer(PRELUDE_SIZE);
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
@ -239,12 +239,10 @@
+ var fd = fs.openSync(process.execPath, 'r');
+ var result = readPrelude(fd);
+ if (result && result.undoPatch) {
+ fs.closeSync(fd);
+ }
+ if (!result || result.undoPatch) {
+ var bindingFs = process.binding('fs');
+ fs.internalModuleStat = bindingFs.internalModuleStat;
+ fs.internalModuleReadFile = bindingFs.internalModuleReadFile;
+ fs.closeSync(fd);
+ }
+ }());
+ }());