Created
May 26, 2015 18:07
-
-
Save joepie91/f81cdbc1b45d52ab4b87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var childProcess = require("child_process"); | |
var electronPath = "./node_modules/electron-prebuilt/dist/electron"; | |
var electronParameters = ["."]; | |
var electronProcess = null; | |
var electronStopping = false; | |
startElectron = function(){ | |
electronProcess = childProcess.spawn(electronPath, electronParameters); | |
electronProcess.stdout.pipe(process.stdout) | |
electronProcess.on("close", function(code, signal){ | |
if (electronStopping) { | |
console.log("Restarting electron as requested..."); | |
} else { | |
console.log("Electron exited with code " + code + ", restarting..."); | |
} | |
startElectron(); | |
}); | |
} | |
restartElectron = function(){ | |
if (electronProcess != null) { | |
electronStopping = true; | |
electronProcess.kill(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment