Merge pull request #5611 from jviotti/fix/invalid-archive-asar-exec
Override `child_process.execFile` asar patch for `child_process.exec`
This commit is contained in:
commit
844f9e989b
2 changed files with 41 additions and 0 deletions
|
@ -589,6 +589,23 @@
|
||||||
return mkdirSync(p, mode)
|
return mkdirSync(p, mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Executing a command string containing a path to an asar
|
||||||
|
// archive confuses `child_process.execFile`, which is internally
|
||||||
|
// called by `child_process.{exec,execSync}`, causing
|
||||||
|
// Electron to consider the full command as a single path
|
||||||
|
// to an archive.
|
||||||
|
[ 'exec', 'execSync' ].forEach(function (functionName) {
|
||||||
|
var old = child_process[functionName]
|
||||||
|
child_process[functionName] = function () {
|
||||||
|
var processNoAsarOriginalValue = process.noAsar
|
||||||
|
process.noAsar = true
|
||||||
|
var result = old.apply(this, arguments)
|
||||||
|
process.noAsar = processNoAsarOriginalValue
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
overrideAPI(fs, 'open')
|
overrideAPI(fs, 'open')
|
||||||
overrideAPI(child_process, 'execFile')
|
overrideAPI(child_process, 'execFile')
|
||||||
overrideAPISync(process, 'dlopen', 1)
|
overrideAPISync(process, 'dlopen', 1)
|
||||||
|
|
|
@ -555,6 +555,30 @@ describe('asar package', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('child_process.exec', function () {
|
||||||
|
var child_process = require('child_process');
|
||||||
|
var echo = path.join(fixtures, 'asar', 'echo.asar', 'echo')
|
||||||
|
|
||||||
|
it('should not try to extract the command if there is a reference to a file inside an .asar', function (done) {
|
||||||
|
child_process.exec('echo ' + echo + ' foo bar', function (error, stdout) {
|
||||||
|
assert.equal(error, null)
|
||||||
|
assert.equal(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('child_process.execSync', function () {
|
||||||
|
var child_process = require('child_process');
|
||||||
|
var echo = path.join(fixtures, 'asar', 'echo.asar', 'echo')
|
||||||
|
|
||||||
|
it('should not try to extract the command if there is a reference to a file inside an .asar', function (done) {
|
||||||
|
var stdout = child_process.execSync('echo ' + echo + ' foo bar')
|
||||||
|
assert.equal(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('child_process.execFile', function () {
|
describe('child_process.execFile', function () {
|
||||||
var echo, execFile, execFileSync, ref2
|
var echo, execFile, execFileSync, ref2
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
|
|
Loading…
Reference in a new issue