This commit is contained in:
Felix Rieseberg 2017-12-01 17:18:57 -08:00
Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ c5abe96b39
ΠšΠΎΠΌΠΌΠΈΡ‚ 9646f0c99a
1 ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²: 11 Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠΉ ΠΈ 17 ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠΉ

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -8,19 +8,15 @@ const appFolder = path.dirname(process.execPath)
// i.e. my-app/Update.exe
const updateExe = path.resolve(appFolder, '..', 'Update.exe')
const exeName = path.basename(process.execPath)
var spawnedArgs = []
var spawnedProcess
let spawnedArgs = []
let spawnedProcess
var isSameArgs = function (args) {
return (args.length === spawnedArgs.length) && args.every(function (e, i) {
return e === spawnedArgs[i]
})
}
const isSameArgs = (args) => args.length === spawnedArgs.length && args.every((e, i) => e === spawnedArgs[i])
// Spawn a command and invoke the callback when it completes with an error
// and the output from standard out.
var spawnUpdate = function (args, detached, callback) {
var error, errorEmitted, stderr, stdout
let spawnUpdate = function (args, detached, callback) {
let error, errorEmitted, stderr, stdout
try {
// Ensure we don't spawn multiple squirrel processes
@ -33,7 +29,6 @@ var spawnUpdate = function (args, detached, callback) {
return callback(`AutoUpdater process with arguments ${args} is already running`)
} else if (!spawnedProcess) {
spawnedProcess = spawn(updateExe, args, {
detached: detached
detached: detached,
windowsHide: true
})
@ -50,17 +45,16 @@ var spawnUpdate = function (args, detached, callback) {
}
stdout = ''
stderr = ''
spawnedProcess.stdout.on('data', function (data) {
stdout += data
})
spawnedProcess.stderr.on('data', function (data) {
stderr += data
})
spawnedProcess.stdout.on('data', (data) => { stdout += data })
spawnedProcess.stderr.on('data', (data) => { stderr += data })
errorEmitted = false
spawnedProcess.on('error', function (error) {
spawnedProcess.on('error', (error) => {
errorEmitted = true
callback(error)
})
return spawnedProcess.on('exit', function (code, signal) {
spawnedProcess = undefined
spawnedArgs = []