Skip to content

Pass in separate NW.js executable path #2

Description

@TheJaredWilcurt

Scenario

For apps manually "auto-updating":

  1. User downloads v1 of your app that ships with NW 0.30.0
  2. Later the app auto-updates to v2 which ships with NW 0.50.0
  3. The new version is downloaded to nw.App.dataPath + '/v2'
  4. 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
  5. 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).
  6. nw-splasher still works the same, creating a new instance, but now via child_process instead of nw.Window.open

Questions:

  1. 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:

  1. Existing functionality should not be effected (no breaking changes)
  2. 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).
  3. 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).
  4. When passed in a path to any valid file, that file is spawned.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions