fix: allow renaming electron.exe (#15173)

This commit is contained in:
Jeremy Apthorp 2018-10-15 17:26:34 -07:00 committed by GitHub
parent 0c711f690e
commit 30ccb6aea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 0 deletions

View file

@ -1,6 +1,7 @@
const assert = require('assert')
const Module = require('module')
const path = require('path')
const fs = require('fs')
const { remote } = require('electron')
const { BrowserWindow } = remote
const { closeWindow } = require('./window-helpers')
@ -24,6 +25,22 @@ describe('modules support', () => {
done()
})
})
if (process.platform === 'win32') {
it('can be required if electron.exe is renamed', () => {
const { execPath } = remote.process
const testExecPath = path.join(path.dirname(execPath), 'test.exe')
fs.copyFileSync(execPath, testExecPath)
try {
const runasFixture = path.join(fixtures, 'module', 'runas-renamed.js')
assert.ok(fs.existsSync(runasFixture))
const child = require('child_process').spawnSync(testExecPath, [runasFixture])
assert.strictEqual(child.status, 0)
} finally {
fs.unlinkSync(testExecPath)
}
})
}
})
// TODO(alexeykuzmin): Disabled during the Chromium 62 (Node.js 9) upgrade.