-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: require node-gyp@^8.4.0 & handle old Electron versions (#907)
Co-authored-by: Mark Lee <[email protected]> Co-authored-by: Mark Lee <[email protected]>
- Loading branch information
1 parent
e3754a5
commit 9d64870
Showing
5 changed files
with
111 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { EventEmitter } from 'events'; | ||
import { expect } from 'chai'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
|
||
import { cleanupTestModule, resetTestModule } from './helpers/module-setup'; | ||
import { NodeGyp } from '../src/module-type/node-gyp'; | ||
import { Rebuilder } from '../src/rebuild'; | ||
|
||
describe('node-gyp', () => { | ||
describe('buildArgs', () => { | ||
const testModulePath = path.resolve(os.tmpdir(), 'electron-rebuild-test'); | ||
|
||
before(async () => await resetTestModule(testModulePath, false)); | ||
after(async () => await cleanupTestModule(testModulePath)); | ||
|
||
function nodeGypArgsForElectronVersion(electronVersion: string): Promise<string[]> { | ||
const rebuilder = new Rebuilder({ | ||
buildPath: testModulePath, | ||
electronVersion: electronVersion, | ||
lifecycle: new EventEmitter() | ||
}); | ||
const nodeGyp = new NodeGyp(rebuilder, testModulePath); | ||
return nodeGyp.buildArgs([]); | ||
} | ||
|
||
context('sufficiently old Electron versions which lack a bundled config.gypi', () => { | ||
it('adds --force-process-config for < 14', async () => { | ||
const args = await nodeGypArgsForElectronVersion('12.0.0'); | ||
expect(args).to.include('--force-process-config'); | ||
}); | ||
|
||
it('adds --force-process-config for between 14.0.0 and < 14.2.0', async () => { | ||
const args = await nodeGypArgsForElectronVersion('14.1.0'); | ||
expect(args).to.include('--force-process-config'); | ||
}); | ||
|
||
it('adds --force-process-config for versions between 15.0.0 and < 15.3.0', async () => { | ||
const args = await nodeGypArgsForElectronVersion('15.2.0'); | ||
expect(args).to.include('--force-process-config'); | ||
}); | ||
}); | ||
|
||
context('for sufficiently new Electron versions', () => { | ||
it('does not add --force-process-config for ^14.2.0', async () => { | ||
const args = await nodeGypArgsForElectronVersion('14.2.0'); | ||
expect(args).to.not.include('--force-process-config'); | ||
}); | ||
|
||
it('does not add --force-process-config for ^15.3.0', async () => { | ||
const args = await nodeGypArgsForElectronVersion('15.3.0'); | ||
expect(args).to.not.include('--force-process-config'); | ||
}); | ||
|
||
it('does not add --force-process-config for >= 16.0.0', async () => { | ||
const args = await nodeGypArgsForElectronVersion('16.0.0-alpha.1'); | ||
expect(args).to.not.include('--force-process-config'); | ||
}); | ||
}); | ||
}); | ||
}); |
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