diff --git a/README.md b/README.md index 97c5233..5eb8b79 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ This will specify the NW.js version we are using. See more in the following Opti // package.json { "scripts": { - "dist": "build --win --mac --linux --x86 --x64 --mirror https://dl.nwjs.io/ .", + // Deprecated. "dist": "build --win --mac --linux --x86 --x64 --mirror https://dl.nwjs.io/ .", + "dist": "build --tasks win-x86,win-x64,linux-x86,linux-x64,mac-x64 --mirror https://dl.nwjs.io/ .", "start": "run --x86 --mirror https://dl.nwjs.io/ ." } } diff --git a/src/bin/build.ts b/src/bin/build.ts index dfacac1..59cb169 100644 --- a/src/bin/build.ts +++ b/src/bin/build.ts @@ -35,6 +35,11 @@ const argv = require('yargs') describe: 'Build for x64 arch', default: Builder.DEFAULT_OPTIONS.x64, }) +.option('tasks', { + type: 'string', + describe: 'List of - to build, separated by comma.', + default: '', +}) .option('chrome-app', { type: 'boolean', describe: 'Build from Chrome App', @@ -62,6 +67,7 @@ const argv = require('yargs') linux: argv.linux, x86: argv.x86, x64: argv.x64, + tasks: argv.tasks.split(','), chromeApp: argv['chrome-app'], mirror: argv.mirror, concurrent: argv.concurrent, diff --git a/src/lib/Builder.ts b/src/lib/Builder.ts index 91d2ebe..53bd76f 100644 --- a/src/lib/Builder.ts +++ b/src/lib/Builder.ts @@ -30,6 +30,7 @@ interface IBuilderOptions { linux?: boolean; x86?: boolean; x64?: boolean; + tasks?: string[]; chromeApp?: boolean; mirror?: string; concurrent?: boolean; @@ -44,6 +45,7 @@ export class Builder { linux: false, x86: false, x64: false, + tasks: [], chromeApp: false, mirror: Downloader.DEFAULT_OPTIONS.mirror, concurrent: false, @@ -73,6 +75,18 @@ export class Builder { }); }); + for(const task of this.options.tasks) { + + const [ platform, arch ] = task.split('-'); + + if([ 'win', 'mac', 'linux' ].indexOf(platform) >= 0) { + if([ 'x86', 'x64' ].indexOf(arch) >= 0) { + tasks.push([ platform, arch ]); + } + } + + } + if(!this.options.mute) { console.info('Starting building tasks...', { tasks, diff --git a/test/Builder.js b/test/Builder.js index 6fe9885..2983f2b 100644 --- a/test/Builder.js +++ b/test/Builder.js @@ -6,18 +6,18 @@ import { spawnAsync } from '../dist/lib/util'; const dir = './assets/project/'; -test('commandline --concurrent', async (t) => { +test.serial('commandline --concurrent', async (t) => { const mirror = process.env.CI ? '' : '--mirror https://npm.taobao.org/mirrors/nwjs/'; - const { code, signal } = await spawnAsync('node', `./dist/bin/build.js --win --mac --linux --x64 --concurrent ${ mirror } ${ dir }`.split(' '), { + const { code, signal } = await spawnAsync('node', `./dist/bin/build.js --tasks win-x64,linux-x64,mac-x64 --concurrent ${ mirror } ${ dir }`.split(' '), { stdio: 'inherit', }); t.is(code, 0); }); -test.skip('module', async (t) => { +test.serial('module', async (t) => { const mirror = process.env.CI ? undefined : 'https://npm.taobao.org/mirrors/nwjs/';