Skip to content

Commit 72ca5b5

Browse files
committed
don't override mainModule when start from node-main
related to nwjs#371
1 parent 98662fa commit 72ca5b5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/renderer/shell_content_renderer_client.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,15 @@ void ShellContentRendererClient::InstallNodeSymbols(
211211
if (use_node) {
212212
v8::Local<v8::Script> script = v8::Script::New(v8::String::New(
213213
// Make node's relative modules work
214+
"if (!process.mainModule.filename) {"
214215
#if defined(OS_WIN)
215216
"process.mainModule.filename = decodeURIComponent(window.location.pathname.substr(1));"
216217
#else
217218
"process.mainModule.filename = decodeURIComponent(window.location.pathname);"
218219
#endif
219220
"process.mainModule.paths = global.require('module')._nodeModulePaths(process.cwd());"
221+
"process.mainModule.loaded = true;"
222+
"}"
220223
));
221224
script->Run();
222225
}

0 commit comments

Comments
 (0)