Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass the flags to scripts #93

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as options from './utils/options';
const commandMap = {
ADD: { add: true },
BIN: { bin: true },
CACHE: { cache: true },
BUILD: { build: true },
CACHE_CLEAN: { clean: true },
CACHE_DIR: { dir: true },
CACHE_LIST: { list: true, ls: true },
Expand Down Expand Up @@ -103,7 +103,7 @@ function runCommandFromCli(args: options.Args, flags: options.Flags) {
return commands.add(commands.toAddOptions(commandArgs, flags));
} else if (commandMap.BIN[command]) {
return commands.bin(commands.toBinOptions(commandArgs, flags));
} else if (commandMap.CACHE[command]) {
} else if (commandMap.BUILD[command]) {
return commands.build(commands.toBuildOptions(commandArgs, flags));
} else if (commandMap.CACHE_CLEAN[command]) {
if (commandMap.CACHE_DIR[command]) {
Expand Down
37 changes: 36 additions & 1 deletion src/commands/__tests__/build.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
// @flow
import { build, toBuildOptions } from '../build';
import { copyFixtureIntoTempDir } from 'jest-fixtures';
import * as boltRun from '../run';

test('bolt build');
jest.mock('../run');

describe('bolt build', () => {
it('should call run with build script with no flags or arguments', async () => {
await build(toBuildOptions([], { '--': [] }));
expect(boltRun.run).toHaveBeenCalledWith({
cwd: undefined,
script: 'build',
scriptArgs: [],
scriptFlags: []
});
});

it('should call run with build script with flags and arguments', async () => {
await build(
toBuildOptions(['Babel'], {
compress: true,
target: 'Node8',
cwd: 'dummyPattern/dummyPath',
'--': []
})
);
expect(boltRun.run).toHaveBeenCalledWith({
cwd: 'dummyPattern/dummyPath',
script: 'build',
scriptArgs: ['Babel'],
scriptFlags: [
'--compress',
'--target=Node8',
'--cwd=dummyPattern/dummyPath'
]
});
});
});
37 changes: 36 additions & 1 deletion src/commands/__tests__/check.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
// @flow
import { check, toCheckOptions } from '../check';
import { copyFixtureIntoTempDir } from 'jest-fixtures';
import * as boltRun from '../run';

test('bolt check');
jest.mock('../run');

describe('bolt check', () => {
it('should call run with build script with no flags or arguments', async () => {
await check(toCheckOptions([], { '--': [] }));
expect(boltRun.run).toHaveBeenCalledWith({
cwd: undefined,
script: 'check',
scriptArgs: [],
scriptFlags: []
});
});

it('should call run with build script with flags and arguments', async () => {
await check(
toCheckOptions(['Babel'], {
compress: true,
target: 'Node8',
cwd: 'dummyPattern/dummyPath',
'--': []
})
);
expect(boltRun.run).toHaveBeenCalledWith({
cwd: 'dummyPattern/dummyPath',
script: 'check',
scriptArgs: ['Babel'],
scriptFlags: [
'--compress',
'--target=Node8',
'--cwd=dummyPattern/dummyPath'
]
});
});
});
37 changes: 36 additions & 1 deletion src/commands/__tests__/doc.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
// @flow
import { doc, toDocOptions } from '../doc';
import { copyFixtureIntoTempDir } from 'jest-fixtures';
import * as boltRun from '../run';

test('bolt doc');
jest.mock('../run');

describe('bolt doc', () => {
it('should call run with build script with no flags or arguments', async () => {
await doc(toDocOptions([], { '--': [] }));
expect(boltRun.run).toHaveBeenCalledWith({
cwd: undefined,
script: 'doc',
scriptArgs: [],
scriptFlags: []
});
});

it('should call run with build script with flags and arguments', async () => {
await doc(
toDocOptions(['Babel'], {
compress: true,
target: 'Node8',
cwd: 'dummyPattern/dummyPath',
'--': []
})
);
expect(boltRun.run).toHaveBeenCalledWith({
cwd: 'dummyPattern/dummyPath',
script: 'doc',
scriptArgs: ['Babel'],
scriptFlags: [
'--compress',
'--target=Node8',
'--cwd=dummyPattern/dummyPath'
]
});
});
});
37 changes: 36 additions & 1 deletion src/commands/__tests__/format.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
// @flow
import { format, toFormatOptions } from '../format';
import { copyFixtureIntoTempDir } from 'jest-fixtures';
import * as boltRun from '../run';

test('bolt format');
jest.mock('../run');

describe('bolt format', () => {
it('should call run with build script with no flags or arguments', async () => {
await format(toFormatOptions([], { '--': [] }));
expect(boltRun.run).toHaveBeenCalledWith({
cwd: undefined,
script: 'format',
scriptArgs: [],
scriptFlags: []
});
});

it('should call run with build script with flags and arguments', async () => {
await format(
toFormatOptions(['Babel'], {
compress: true,
target: 'Node8',
cwd: 'dummyPattern/dummyPath',
'--': []
})
);
expect(boltRun.run).toHaveBeenCalledWith({
cwd: 'dummyPattern/dummyPath',
script: 'format',
scriptArgs: ['Babel'],
scriptFlags: [
'--compress',
'--target=Node8',
'--cwd=dummyPattern/dummyPath'
]
});
});
});
37 changes: 36 additions & 1 deletion src/commands/__tests__/lint.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
// @flow
import { lint, toLintOptions } from '../lint';
import { copyFixtureIntoTempDir } from 'jest-fixtures';
import * as boltRun from '../run';

test('bolt lint');
jest.mock('../run');

describe('bolt lint', () => {
it('should call run with build script with no flags or arguments', async () => {
await lint(toLintOptions([], { '--': [] }));
expect(boltRun.run).toHaveBeenCalledWith({
cwd: undefined,
script: 'lint',
scriptArgs: [],
scriptFlags: []
});
});

it('should call run with build script with flags and arguments', async () => {
await lint(
toLintOptions(['Babel'], {
compress: true,
target: 'Node8',
cwd: 'dummyPattern/dummyPath',
'--': []
})
);
expect(boltRun.run).toHaveBeenCalledWith({
cwd: 'dummyPattern/dummyPath',
script: 'lint',
scriptArgs: ['Babel'],
scriptFlags: [
'--compress',
'--target=Node8',
'--cwd=dummyPattern/dummyPath'
]
});
});
});
37 changes: 36 additions & 1 deletion src/commands/__tests__/test.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
// @flow
import { test as test_, toTestOptions } from '../test';
import { copyFixtureIntoTempDir } from 'jest-fixtures';
import * as boltRun from '../run';

test('bolt test');
jest.mock('../run');

describe('bolt lint', () => {
it('should call run with build script with no flags or arguments', async () => {
await test_(toTestOptions([], { '--': [] }));
expect(boltRun.run).toHaveBeenCalledWith({
cwd: undefined,
script: 'test',
scriptArgs: [],
scriptFlags: []
});
});

it('should call run with build script with flags and arguments', async () => {
await test_(
toTestOptions(['Babel'], {
compress: true,
target: 'Node8',
cwd: 'dummyPattern/dummyPath',
'--': []
})
);
expect(boltRun.run).toHaveBeenCalledWith({
cwd: 'dummyPattern/dummyPath',
script: 'test',
scriptArgs: ['Babel'],
scriptFlags: [
'--compress',
'--target=Node8',
'--cwd=dummyPattern/dummyPath'
]
});
});
});
9 changes: 6 additions & 3 deletions src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { run } from './run';

export type BuildOptions = {|
cwd?: string,
args: options.Args
args: options.Args,
scriptFlags: Array<string>
|};

export function toBuildOptions(
Expand All @@ -14,14 +15,16 @@ export function toBuildOptions(
): BuildOptions {
return {
cwd: options.string(flags.cwd, 'cwd'),
args: args
args: args,
scriptFlags: options.toScriptFlags(flags)
};
}

export async function build(opts: BuildOptions) {
await run({
cwd: opts.cwd,
script: 'build',
scriptArgs: opts.args
scriptArgs: opts.args,
scriptFlags: opts.scriptFlags
});
}
9 changes: 6 additions & 3 deletions src/commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { run } from './run';

export type CheckOptions = {|
cwd?: string,
args: options.Args
args: options.Args,
scriptFlags: Array<string>
|};

export function toCheckOptions(
Expand All @@ -14,14 +15,16 @@ export function toCheckOptions(
): CheckOptions {
return {
cwd: options.string(flags.cwd, 'cwd'),
args: args
args: args,
scriptFlags: options.toScriptFlags(flags)
};
}

export async function check(opts: CheckOptions) {
await run({
cwd: opts.cwd,
script: 'check',
scriptArgs: opts.args
scriptArgs: opts.args,
scriptFlags: opts.scriptFlags
});
}
9 changes: 6 additions & 3 deletions src/commands/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { run } from './run';

export type DocOptions = {|
cwd?: string,
args: options.Args
args: options.Args,
scriptFlags: Array<string>
|};

export function toDocOptions(
Expand All @@ -14,14 +15,16 @@ export function toDocOptions(
): DocOptions {
return {
cwd: options.string(flags.cwd, 'cwd'),
args: args
args: args,
scriptFlags: options.toScriptFlags(flags)
};
}

export async function doc(opts: DocOptions) {
await run({
cwd: opts.cwd,
script: 'doc',
scriptArgs: opts.args
scriptArgs: opts.args,
scriptFlags: opts.scriptFlags
});
}
9 changes: 6 additions & 3 deletions src/commands/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { run } from './run';

export type FormatOptions = {|
cwd?: string,
args: options.Args
args: options.Args,
scriptFlags: Array<string>
|};

export function toFormatOptions(
Expand All @@ -14,14 +15,16 @@ export function toFormatOptions(
): FormatOptions {
return {
cwd: options.string(flags.cwd, 'cwd'),
args: args
args: args,
scriptFlags: options.toScriptFlags(flags)
};
}

export async function format(opts: FormatOptions) {
await run({
cwd: opts.cwd,
script: 'format',
scriptArgs: opts.args
scriptArgs: opts.args,
scriptFlags: opts.scriptFlags
});
}
Loading