Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
feat(Builder): add tasks option and deprecate flag options
Browse files Browse the repository at this point in the history
  • Loading branch information
evshiron committed May 10, 2017
1 parent e659189 commit 974d9e0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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/ ."
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/bin/build.ts
Expand Up @@ -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 <PLATFORM>-<ARCH> to build, separated by comma.',
default: '',
})
.option('chrome-app', {
type: 'boolean',
describe: 'Build from Chrome App',
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions src/lib/Builder.ts
Expand Up @@ -30,6 +30,7 @@ interface IBuilderOptions {
linux?: boolean;
x86?: boolean;
x64?: boolean;
tasks?: string[];
chromeApp?: boolean;
mirror?: string;
concurrent?: boolean;
Expand All @@ -44,6 +45,7 @@ export class Builder {
linux: false,
x86: false,
x64: false,
tasks: [],
chromeApp: false,
mirror: Downloader.DEFAULT_OPTIONS.mirror,
concurrent: false,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions test/Builder.js
Expand Up @@ -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/';

Expand Down

0 comments on commit 974d9e0

Please sign in to comment.