Scenario
For apps manually "auto-updating":
- User downloads v1 of your app that ships with NW 0.30.0
- Later the app auto-updates to v2 which ships with NW 0.50.0
- The new version is downloaded to
nw.App.dataPath + '/v2'
- The original global install still points to
0.30.0 on launch, but the v1 code's splash screen always checks to see if there are newer versions
- It finds the newer version, and instead of launching a new window instance in the current NW.js version (30), it points to the newer NW.js version that was downloaded (50).
- nw-splasher still works the same, creating a new instance, but now via
child_process instead of nw.Window.open
Questions:
- Which
child_process method should be used for this (exec, spawn, fork, etc.)
- We don't want the main window to die when the parent (splash screen) is closed
- We don't want the splash screen window's process to remain running in the background while the main window is displayed (zombie process in task manager)
Answers:
From: Brian Bothwell (@sysrage in Gitter chat)
you may want to use spawn() with detached:true. I've seen cases where the first app won't close because a child process is still open.
child_process.spawn(path.resolve(finalAppDirectory, launcher), { cwd: finalAppDirectory, detached: true });
Acceptance Criteria:
- Existing functionality should not be effected (no breaking changes)
- Update API documentation in
README.md to include an optional String called executablePath and a description of:
- If passed in, this path will be used to spawn the new executable (presumed to be a different/newer NW.js executable) instead of creating the a new window from the same NW.js executable. The
url and newWindowOptions params are ignored if the executablePath exists, otherwise are used as fallbacks if the executable cannot be found. If executable not found, nw-splasher will attempt to launch the window from the current NW.js executable in a separate process (as if executablePath was not used).
- Add in validation warnings if the
executablePath is truthy but not a string. Also warn if executablePath is a string, but the file does not exist on the system. (pull in fs-extra for safer existsSync check).
- When passed in a path to any valid file, that file is spawned.
- When passed in the path to an NW.js app, it should launch just like you had double-clicked the icon for it on the OS.
- It should find it's own
package.json and follow it's window instructions.
- If those instructions include
show: false, and it's main also uses the nw-splasher library, and it communicates on the same web socket port, calling nwSplasher.closeSplashAndShowApp(), then the splash screen executable should completely close and not be found in the system's Task Manager while the new window is still running.
Scenario
For apps manually "auto-updating":
nw.App.dataPath + '/v2'0.30.0on launch, but the v1 code's splash screen always checks to see if there are newer versionschild_processinstead ofnw.Window.openQuestions:
child_processmethod should be used for this (exec, spawn, fork, etc.)Answers:
From: Brian Bothwell (@sysrage in Gitter chat)
Acceptance Criteria:
README.mdto include an optional String calledexecutablePathand a description of:urlandnewWindowOptionsparams are ignored if theexecutablePathexists, otherwise are used as fallbacks if the executable cannot be found. If executable not found, nw-splasher will attempt to launch the window from the current NW.js executable in a separate process (as ifexecutablePathwas not used).executablePathis truthy but not a string. Also warn ifexecutablePathis a string, but the file does not exist on the system. (pull infs-extrafor saferexistsSynccheck).package.jsonand follow it's window instructions.show: false, and it'smainalso uses thenw-splasherlibrary, and it communicates on the same web socket port, callingnwSplasher.closeSplashAndShowApp(), then the splash screen executable should completely close and not be found in the system's Task Manager while the new window is still running.