Add --only option to build whitelisted modules
Adapted from changes originally by Jan Kuri <jkuri88@gmail.com> Fixes #151
This commit is contained in:
Родитель
c2e490053e
Коммит
930ec930a6
|
@ -62,6 +62,8 @@ Options:
|
|||
on macOS and Linux
|
||||
-s, --sequential Rebuild modules sequentially, this is enabled by
|
||||
default on Windows
|
||||
-o, --only Only build specified module, or comma separated
|
||||
list of modules. All others are ignored.
|
||||
|
||||
Copyright 2016
|
||||
```
|
||||
|
|
|
@ -23,6 +23,8 @@ const yargs = argParser
|
|||
.alias('m', 'module-dir')
|
||||
.describe('w', 'A specific module to build, or comma separated list of modules')
|
||||
.alias('w', 'which-module')
|
||||
.describe('o', 'Only build specified module, or comma separated list of modules. All others are ignored.')
|
||||
.alias('o', 'only')
|
||||
.describe('e', 'The path to electron-prebuilt')
|
||||
.alias('e', 'electron-prebuilt-dir')
|
||||
.describe('d', 'Custom header tarball URL')
|
||||
|
@ -92,6 +94,7 @@ process.on('unhandledRejection', handler);
|
|||
|
||||
const redraw = (moduleName?: string) => {
|
||||
if (moduleName) lastModuleName = moduleName;
|
||||
|
||||
if (argv.p) {
|
||||
rebuildSpinner.text = `Building modules: ${modulesDone}/${moduleTotal}`;
|
||||
} else {
|
||||
|
@ -104,6 +107,7 @@ process.on('unhandledRejection', handler);
|
|||
electronVersion: electronPrebuiltVersion,
|
||||
arch: argv.a || process.arch,
|
||||
extraModules: argv.w ? argv.w.split(',') : [],
|
||||
onlyModules: argv.o ? argv.o.split(',') : [],
|
||||
force: argv.f,
|
||||
headerURL: argv.d,
|
||||
types: argv.t ? argv.t.split(',') : ['prod', 'optional'],
|
||||
|
|
|
@ -15,6 +15,7 @@ export interface RebuildOptions {
|
|||
electronVersion: string;
|
||||
arch?: string;
|
||||
extraModules?: string[];
|
||||
onlyModules?: string[];
|
||||
force?: boolean;
|
||||
headerURL?: string;
|
||||
types?: ModuleType[];
|
||||
|
@ -55,6 +56,7 @@ class Rebuilder {
|
|||
public electronVersion: string;
|
||||
public arch: string;
|
||||
public extraModules: string[];
|
||||
public onlyModules: string[];
|
||||
public force: boolean;
|
||||
public headerURL: string;
|
||||
public types: ModuleType[];
|
||||
|
@ -66,6 +68,7 @@ class Rebuilder {
|
|||
this.electronVersion = options.electronVersion;
|
||||
this.arch = options.arch || process.arch;
|
||||
this.extraModules = options.extraModules || [];
|
||||
this.onlyModules = options.onlyModules || [];
|
||||
this.force = options.force || false;
|
||||
this.headerURL = options.headerURL || 'https://atom.io/download/electron';
|
||||
this.types = options.types || defaultTypes;
|
||||
|
@ -240,7 +243,8 @@ class Rebuilder {
|
|||
}
|
||||
this.realModulePaths.add(realPath);
|
||||
|
||||
if (this.prodDeps[`${prefix}${modulePath}`]) {
|
||||
if (this.prodDeps[`${prefix}${modulePath}`] &&
|
||||
this.onlyModules.length === 0 || this.onlyModules.includes(modulePath)) {
|
||||
this.rebuilds.push(() => this.rebuildModuleAt(realPath));
|
||||
}
|
||||
|
||||
|
@ -310,7 +314,7 @@ function doRebuild(options: any, ...args: any[]) {
|
|||
if (typeof options === 'object') {
|
||||
return rebuildWithOptions(options as RebuildOptions);
|
||||
}
|
||||
console.warn('You are using the depreceated electron-rebuild API, please switch to using the options object instead');
|
||||
console.warn('You are using the deprecated electron-rebuild API, please switch to using the options object instead');
|
||||
return rebuildWithOptions((<Function>createOptions)(options, ...args));
|
||||
}
|
||||
|
||||
|
@ -321,6 +325,7 @@ export type RebuildFunctionWithArgs = (
|
|||
electronVersion: string,
|
||||
arch?: string,
|
||||
extraModules?: string[],
|
||||
onlyModules?: string[],
|
||||
force?: boolean,
|
||||
headerURL?: string,
|
||||
types?: ModuleType[],
|
||||
|
@ -335,6 +340,7 @@ export function createOptions(
|
|||
electronVersion: string,
|
||||
arch: string,
|
||||
extraModules: string[],
|
||||
onlyModules: string[],
|
||||
force: boolean,
|
||||
headerURL: string,
|
||||
types: ModuleType[],
|
||||
|
@ -345,6 +351,7 @@ export function createOptions(
|
|||
electronVersion,
|
||||
arch,
|
||||
extraModules,
|
||||
onlyModules,
|
||||
force,
|
||||
headerURL,
|
||||
types,
|
||||
|
|
|
@ -94,7 +94,7 @@ describe('rebuilder', () => {
|
|||
|
||||
it('should skip the rebuild step when disabled', async () => {
|
||||
await rebuild(testModulePath, '1.4.12', process.arch);
|
||||
const rebuilder = rebuild(testModulePath, '1.4.12', process.arch, [], false);
|
||||
const rebuilder = rebuild(testModulePath, '1.4.12', process.arch, [], [], false);
|
||||
let skipped = 0;
|
||||
rebuilder.lifecycle.on('module-skip', () => {
|
||||
skipped++;
|
||||
|
@ -105,7 +105,7 @@ describe('rebuilder', () => {
|
|||
|
||||
it('should rebuild all modules again when disabled but the electron ABI bumped', async () => {
|
||||
await rebuild(testModulePath, '1.4.12', process.arch);
|
||||
const rebuilder = rebuild(testModulePath, '1.6.0', process.arch, [], false);
|
||||
const rebuilder = rebuild(testModulePath, '1.6.0', process.arch, [], [], false);
|
||||
let skipped = 0;
|
||||
rebuilder.lifecycle.on('module-skip', () => {
|
||||
skipped++;
|
||||
|
@ -116,7 +116,7 @@ describe('rebuilder', () => {
|
|||
|
||||
it('should rebuild all modules again when enabled', async () => {
|
||||
await rebuild(testModulePath, '1.4.12', process.arch);
|
||||
const rebuilder = rebuild(testModulePath, '1.4.12', process.arch, [], true);
|
||||
const rebuilder = rebuild(testModulePath, '1.4.12', process.arch, [], [], true);
|
||||
let skipped = 0;
|
||||
rebuilder.lifecycle.on('module-skip', () => {
|
||||
skipped++;
|
||||
|
@ -125,4 +125,27 @@ describe('rebuilder', () => {
|
|||
expect(skipped).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('only rebuild', function() {
|
||||
this.timeout(2 * 60 * 1000);
|
||||
|
||||
beforeEach(resetTestModule);
|
||||
afterEach(async () => await fs.remove(testModulePath));
|
||||
|
||||
it('should rebuild only specified modules', async () => {
|
||||
const rebuilder = rebuild(testModulePath, '1.4.12', process.arch, [], ['ffi'], true);
|
||||
let built = 0;
|
||||
rebuilder.lifecycle.on('module-done', () => built++);
|
||||
await rebuilder;
|
||||
expect(built).to.equal(1);
|
||||
});
|
||||
|
||||
it('should rebuild multiple specified modules via --only option', async () => {
|
||||
const rebuilder = rebuild(testModulePath, '1.4.12', process.arch, [], ['ffi', '@newrelic/native-metrics'], true);
|
||||
let built = 0;
|
||||
rebuilder.lifecycle.on('module-done', () => built++);
|
||||
await rebuilder;
|
||||
expect(built).to.equal(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче