| 
									
										
										
										
											2021-12-06 03:44:41 +01:00
										 |  |  | import * as electron from 'electron/main'; | 
					
						
							| 
									
										
										
										
											2019-01-10 20:54:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  | import * as fs from 'fs'; | 
					
						
							|  |  |  | import * as path from 'path'; | 
					
						
							|  |  |  | import * as url from 'url'; | 
					
						
							| 
									
										
										
										
											2020-06-22 19:03:19 -07:00
										 |  |  | const { app, dialog } = electron; | 
					
						
							| 
									
										
										
										
											2019-02-06 10:27:20 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | type DefaultAppOptions = { | 
					
						
							|  |  |  |   file: null | string; | 
					
						
							|  |  |  |   noHelp: boolean; | 
					
						
							|  |  |  |   version: boolean; | 
					
						
							|  |  |  |   webdriver: boolean; | 
					
						
							|  |  |  |   interactive: boolean; | 
					
						
							|  |  |  |   abi: boolean; | 
					
						
							|  |  |  |   modules: string[]; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-11-12 18:28:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  | const Module = require('module'); | 
					
						
							| 
									
										
										
										
											2013-04-17 20:05:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-25 19:11:26 +08:00
										 |  |  | // Parse command line options.
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  | const argv = process.argv.slice(1); | 
					
						
							| 
									
										
										
										
											2017-09-27 23:51:53 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 10:27:20 -08:00
										 |  |  | const option: DefaultAppOptions = { | 
					
						
							| 
									
										
										
										
											2017-09-27 23:51:53 -04:00
										 |  |  |   file: null, | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   noHelp: Boolean(process.env.ELECTRON_NO_HELP), | 
					
						
							| 
									
										
										
										
											2019-02-06 10:27:20 -08:00
										 |  |  |   version: false, | 
					
						
							|  |  |  |   webdriver: false, | 
					
						
							|  |  |  |   interactive: false, | 
					
						
							|  |  |  |   abi: false, | 
					
						
							| 
									
										
										
										
											2017-09-27 23:51:53 -04:00
										 |  |  |   modules: [] | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-09-27 23:51:53 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  | let nextArgIsRequire = false; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | for (const arg of argv) { | 
					
						
							|  |  |  |   if (nextArgIsRequire) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     option.modules.push(arg); | 
					
						
							|  |  |  |     nextArgIsRequire = false; | 
					
						
							|  |  |  |     continue; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } else if (arg === '--version' || arg === '-v') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     option.version = true; | 
					
						
							|  |  |  |     break; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } else if (arg.match(/^--app=/)) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     option.file = arg.split('=')[1]; | 
					
						
							|  |  |  |     break; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } else if (arg === '--interactive' || arg === '-i' || arg === '-repl') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     option.interactive = true; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } else if (arg === '--test-type=webdriver') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     option.webdriver = true; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } else if (arg === '--require' || arg === '-r') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     nextArgIsRequire = true; | 
					
						
							|  |  |  |     continue; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } else if (arg === '--abi' || arg === '-a') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     option.abi = true; | 
					
						
							|  |  |  |     continue; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } else if (arg === '--no-help') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     option.noHelp = true; | 
					
						
							|  |  |  |     continue; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } else if (arg[0] === '-') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     continue; | 
					
						
							| 
									
										
										
										
											2014-08-25 19:11:26 +08:00
										 |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     option.file = arg; | 
					
						
							|  |  |  |     break; | 
					
						
							| 
									
										
										
										
											2014-08-25 19:11:26 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-10-03 11:36:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  | if (nextArgIsRequire) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   console.error('Invalid Usage: --require [file]\n\n"file" is required'); | 
					
						
							|  |  |  |   process.exit(1); | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Set up preload modules
 | 
					
						
							| 
									
										
										
										
											2015-09-26 17:23:34 +02:00
										 |  |  | if (option.modules.length > 0) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   Module._preloadModules(option.modules); | 
					
						
							| 
									
										
										
										
											2015-09-26 17:23:34 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 10:27:20 -08:00
										 |  |  | function loadApplicationPackage (packagePath: string) { | 
					
						
							| 
									
										
										
										
											2016-05-06 21:48:51 +09:00
										 |  |  |   // Add a flag indicating app is started from default app.
 | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   Object.defineProperty(process, 'defaultApp', { | 
					
						
							|  |  |  |     configurable: false, | 
					
						
							|  |  |  |     enumerable: true, | 
					
						
							|  |  |  |     value: true | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2016-05-06 21:48:51 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-24 15:20:59 +08:00
										 |  |  |   try { | 
					
						
							| 
									
										
										
										
											2014-05-24 11:18:06 +08:00
										 |  |  |     // Override app name and version.
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     packagePath = path.resolve(packagePath); | 
					
						
							|  |  |  |     const packageJsonPath = path.join(packagePath, 'package.json'); | 
					
						
							|  |  |  |     let appPath; | 
					
						
							| 
									
										
										
										
											2014-05-24 11:18:06 +08:00
										 |  |  |     if (fs.existsSync(packageJsonPath)) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |       let packageJson; | 
					
						
							| 
									
										
										
										
											2016-05-23 15:00:55 -04:00
										 |  |  |       try { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |         packageJson = require(packageJsonPath); | 
					
						
							| 
									
										
										
										
											2016-05-23 15:00:55 -04:00
										 |  |  |       } catch (e) { | 
					
						
							| 
									
										
										
										
											2022-01-31 12:37:40 +01:00
										 |  |  |         showErrorMessage(`Unable to parse ${packageJsonPath}\n\n${(e as Error).message}`); | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2016-05-23 15:00:55 -04:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-03-28 13:19:41 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-24 09:42:31 -07:00
										 |  |  |       if (packageJson.version) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |         app.setVersion(packageJson.version); | 
					
						
							| 
									
										
										
										
											2016-05-24 09:42:31 -07:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-03-28 13:19:41 -07:00
										 |  |  |       if (packageJson.productName) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |         app.name = packageJson.productName; | 
					
						
							| 
									
										
										
										
											2016-03-28 13:19:41 -07:00
										 |  |  |       } else if (packageJson.name) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |         app.name = packageJson.name; | 
					
						
							| 
									
										
										
										
											2016-03-28 13:19:41 -07:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |       appPath = packagePath; | 
					
						
							| 
									
										
										
										
											2014-05-24 11:18:06 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-05-24 09:33:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-23 15:00:55 -04:00
										 |  |  |     try { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |       const filePath = Module._resolveFilename(packagePath, module, true); | 
					
						
							| 
									
										
										
										
											2021-06-14 17:32:56 -07:00
										 |  |  |       app.setAppPath(appPath || path.dirname(filePath)); | 
					
						
							| 
									
										
										
										
											2016-05-23 15:00:55 -04:00
										 |  |  |     } catch (e) { | 
					
						
							| 
									
										
										
										
											2022-01-31 12:37:40 +01:00
										 |  |  |       showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${(e as Error).message}`); | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |       return; | 
					
						
							| 
									
										
										
										
											2016-05-23 15:00:55 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-05-24 09:41:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-24 11:18:06 +08:00
										 |  |  |     // Run the app.
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     Module._load(packagePath, module, true); | 
					
						
							| 
									
										
										
										
											2016-03-28 18:00:30 -07:00
										 |  |  |   } catch (e) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     console.error('App threw an error during load'); | 
					
						
							| 
									
										
										
										
											2022-01-31 12:37:40 +01:00
										 |  |  |     console.error((e as Error).stack || e); | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     throw e; | 
					
						
							| 
									
										
										
										
											2013-07-24 15:20:59 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-02-04 10:07:19 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 10:27:20 -08:00
										 |  |  | function showErrorMessage (message: string) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   app.focus(); | 
					
						
							|  |  |  |   dialog.showErrorBox('Error launching app', message); | 
					
						
							|  |  |  |   process.exit(1); | 
					
						
							| 
									
										
										
										
											2016-05-23 15:00:55 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-12 00:13:46 +01:00
										 |  |  | async function loadApplicationByURL (appUrl: string) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   const { loadURL } = await import('./default_app'); | 
					
						
							|  |  |  |   loadURL(appUrl); | 
					
						
							| 
									
										
										
										
											2019-03-12 00:13:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | async function loadApplicationByFile (appPath: string) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   const { loadFile } = await import('./default_app'); | 
					
						
							|  |  |  |   loadFile(appPath); | 
					
						
							| 
									
										
										
										
											2016-02-04 10:26:11 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-28 00:10:52 -04:00
										 |  |  | function startRepl () { | 
					
						
							| 
									
										
										
										
											2016-06-13 09:46:33 -07:00
										 |  |  |   if (process.platform === 'win32') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     console.error('Electron REPL not currently supported on Windows'); | 
					
						
							|  |  |  |     process.exit(1); | 
					
						
							| 
									
										
										
										
											2016-06-13 09:46:33 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 19:03:19 -07:00
										 |  |  |   // Prevent quitting.
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   app.on('window-all-closed', () => {}); | 
					
						
							| 
									
										
										
										
											2019-01-15 21:35:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 19:03:19 -07:00
										 |  |  |   const GREEN = '32'; | 
					
						
							|  |  |  |   const colorize = (color: string, s: string) => `\x1b[${color}m${s}\x1b[0m`; | 
					
						
							|  |  |  |   const electronVersion = colorize(GREEN, `v${process.versions.electron}`); | 
					
						
							|  |  |  |   const nodeVersion = colorize(GREEN, `v${process.versions.node}`); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   console.info(`
 | 
					
						
							|  |  |  |     Welcome to the Electron.js REPL \\[._.]/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     You can access all Electron.js modules here as well as Node.js modules. | 
					
						
							|  |  |  |     Using: Node.js ${nodeVersion} and Electron.js ${electronVersion} | 
					
						
							|  |  |  |   `);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const { REPLServer } = require('repl'); | 
					
						
							|  |  |  |   const repl = new REPLServer({ | 
					
						
							|  |  |  |     prompt: '> ' | 
					
						
							|  |  |  |   }).on('exit', () => { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     process.exit(0); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2020-06-22 19:03:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 00:53:46 -07:00
										 |  |  |   function defineBuiltin (context: any, name: string, getter: Function) { | 
					
						
							|  |  |  |     const setReal = (val: any) => { | 
					
						
							|  |  |  |       // Deleting the property before re-assigning it disables the
 | 
					
						
							|  |  |  |       // getter/setter mechanism.
 | 
					
						
							|  |  |  |       delete context[name]; | 
					
						
							|  |  |  |       context[name] = val; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Object.defineProperty(context, name, { | 
					
						
							|  |  |  |       get: () => { | 
					
						
							|  |  |  |         const lib = getter(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         delete context[name]; | 
					
						
							|  |  |  |         Object.defineProperty(context, name, { | 
					
						
							|  |  |  |           get: () => lib, | 
					
						
							|  |  |  |           set: setReal, | 
					
						
							|  |  |  |           configurable: true, | 
					
						
							|  |  |  |           enumerable: false | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return lib; | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       set: setReal, | 
					
						
							|  |  |  |       configurable: true, | 
					
						
							|  |  |  |       enumerable: false | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   defineBuiltin(repl.context, 'electron', () => electron); | 
					
						
							|  |  |  |   for (const api of Object.keys(electron) as (keyof typeof electron)[]) { | 
					
						
							|  |  |  |     defineBuiltin(repl.context, api, () => electron[api]); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 19:03:19 -07:00
										 |  |  |   // Copied from node/lib/repl.js. For better DX, we don't want to
 | 
					
						
							|  |  |  |   // show e.g 'contentTracing' at a higher priority than 'const', so
 | 
					
						
							|  |  |  |   // we only trigger custom tab-completion when no common words are
 | 
					
						
							|  |  |  |   // potentially matches.
 | 
					
						
							|  |  |  |   const commonWords = [ | 
					
						
							|  |  |  |     'async', 'await', 'break', 'case', 'catch', 'const', 'continue', | 
					
						
							|  |  |  |     'debugger', 'default', 'delete', 'do', 'else', 'export', 'false', | 
					
						
							|  |  |  |     'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'let', | 
					
						
							|  |  |  |     'new', 'null', 'return', 'switch', 'this', 'throw', 'true', 'try', | 
					
						
							|  |  |  |     'typeof', 'var', 'void', 'while', 'with', 'yield' | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const electronBuiltins = [...Object.keys(electron), 'original-fs', 'electron']; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const defaultComplete = repl.completer; | 
					
						
							|  |  |  |   repl.completer = (line: string, callback: Function) => { | 
					
						
							|  |  |  |     const lastSpace = line.lastIndexOf(' '); | 
					
						
							|  |  |  |     const currentSymbol = line.substring(lastSpace + 1, repl.cursor); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const filterFn = (c: string) => c.startsWith(currentSymbol); | 
					
						
							|  |  |  |     const ignores = commonWords.filter(filterFn); | 
					
						
							|  |  |  |     const hits = electronBuiltins.filter(filterFn); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!ignores.length && hits.length) { | 
					
						
							|  |  |  |       callback(null, [hits, currentSymbol]); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       defaultComplete.apply(repl, [line, callback]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2016-03-22 13:34:46 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-04 10:07:19 -08:00
										 |  |  | // Start the specified app if there is one specified in command line, otherwise
 | 
					
						
							|  |  |  | // start the default app.
 | 
					
						
							|  |  |  | if (option.file && !option.webdriver) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   const file = option.file; | 
					
						
							|  |  |  |   const protocol = url.parse(file).protocol; | 
					
						
							|  |  |  |   const extension = path.extname(file); | 
					
						
							| 
									
										
										
										
											2018-07-17 09:23:44 +02:00
										 |  |  |   if (protocol === 'http:' || protocol === 'https:' || protocol === 'file:' || protocol === 'chrome:') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     loadApplicationByURL(file); | 
					
						
							| 
									
										
										
										
											2016-02-04 10:33:22 -08:00
										 |  |  |   } else if (extension === '.html' || extension === '.htm') { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     loadApplicationByFile(path.resolve(file)); | 
					
						
							| 
									
										
										
										
											2016-02-04 10:26:11 -08:00
										 |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     loadApplicationPackage(file); | 
					
						
							| 
									
										
										
										
											2016-02-04 10:26:11 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-08-25 19:11:26 +08:00
										 |  |  | } else if (option.version) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   console.log('v' + process.versions.electron); | 
					
						
							|  |  |  |   process.exit(0); | 
					
						
							| 
									
										
										
										
											2017-11-10 14:58:21 -08:00
										 |  |  | } else if (option.abi) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   console.log(process.versions.modules); | 
					
						
							|  |  |  |   process.exit(0); | 
					
						
							| 
									
										
										
										
											2017-09-27 14:23:42 -04:00
										 |  |  | } else if (option.interactive) { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   startRepl(); | 
					
						
							| 
									
										
										
										
											2017-09-27 14:23:42 -04:00
										 |  |  | } else { | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   if (!option.noHelp) { | 
					
						
							|  |  |  |     const welcomeMessage = `
 | 
					
						
							|  |  |  | Electron ${process.versions.electron} - Build cross platform desktop apps with JavaScript, HTML, and CSS | 
					
						
							|  |  |  | Usage: electron [options] [path] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | A path to an Electron app may be specified. It must be one of the following: | 
					
						
							|  |  |  |   - index.js file. | 
					
						
							|  |  |  |   - Folder containing a package.json file. | 
					
						
							|  |  |  |   - Folder containing an index.js file. | 
					
						
							|  |  |  |   - .html/.htm file. | 
					
						
							|  |  |  |   - http://, https://, or file:// URL.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Options: | 
					
						
							|  |  |  |   -i, --interactive     Open a REPL to the main process. | 
					
						
							|  |  |  |   -r, --require         Module to preload (option can be repeated). | 
					
						
							|  |  |  |   -v, --version         Print the version. | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   -a, --abi             Print the Node ABI version.`;
 | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |     console.log(welcomeMessage); | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-10-06 23:29:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   loadApplicationByFile('index.html'); | 
					
						
							| 
									
										
										
										
											2017-09-28 00:10:52 -04:00
										 |  |  | } |