Merge pull request #7116 from electron/restore-no-asar
Restore process.noAsar in finally block
This commit is contained in:
commit
e561608c0d
2 changed files with 13 additions and 3 deletions
|
@ -675,9 +675,11 @@
|
||||||
childProcess[functionName] = function () {
|
childProcess[functionName] = function () {
|
||||||
const processNoAsarOriginalValue = process.noAsar
|
const processNoAsarOriginalValue = process.noAsar
|
||||||
process.noAsar = true
|
process.noAsar = true
|
||||||
const result = old.apply(this, arguments)
|
try {
|
||||||
process.noAsar = processNoAsarOriginalValue
|
return old.apply(this, arguments)
|
||||||
return result
|
} finally {
|
||||||
|
process.noAsar = processNoAsarOriginalValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -744,6 +744,14 @@ describe('asar package', function () {
|
||||||
fs.readdirSync(asar)
|
fs.readdirSync(asar)
|
||||||
}, /ENOTDIR/)
|
}, /ENOTDIR/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('is reset to its original value when execSync throws an error', function () {
|
||||||
|
process.noAsar = false
|
||||||
|
assert.throws(function () {
|
||||||
|
ChildProcess.execSync(path.join(__dirname, 'does-not-exist.txt'))
|
||||||
|
})
|
||||||
|
assert.equal(process.noAsar, false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue