From 7a23add23b51d5c107510504272942b509fe0c99 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 24 Aug 2015 21:14:38 +0800 Subject: [PATCH] Support index.js module resolution at startup of Electron. --- atom/browser/lib/init.coffee | 5 ++++- docs/tutorial/quick-start.md | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 069eed8d1b53..1299364d2fa6 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -92,5 +92,8 @@ app.setAppPath packagePath # Load the chrome extension support. require './chrome-extension' +# Set main startup script of the app. +mainStartupScript = packageJson.main or 'index.js' + # Finally load app's main.js and transfer control to C++. -Module._load path.join(packagePath, packageJson.main), Module, true +Module._load path.join(packagePath, mainStartupScript), Module, true diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index 197cf0d3b32b..8fc696e0bcda 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -67,6 +67,9 @@ like this: } ``` +__Note__: If the `main` field is not present in `package.json`, Electron will +attempt to load an `index.js`. + The `main.js` should create windows and handle system events, a typical example being: