forked from OKEAMAH/bolt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexec.js
More file actions
30 lines (27 loc) · 749 Bytes
/
exec.js
File metadata and controls
30 lines (27 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// @flow
import Project from '../Project';
import Package from '../Package';
import * as options from '../utils/options';
import execCommand from '../utils/execCommand';
export type ExecOptions = {|
cwd?: string,
command: string,
commandArgs: options.Args
|};
export function toExecOptions(
args: options.Args,
flags: options.Flags
): ExecOptions {
let [command, ...commandArgs] = flags['--'] || [];
return {
cwd: options.string(flags.cwd, 'cwd'),
command,
commandArgs
};
}
export async function exec(opts: ExecOptions) {
let cwd = opts.cwd || process.cwd();
let project = await Project.init(cwd);
let pkg = await Package.closest(cwd);
return await execCommand(project, pkg, opts.command, opts.commandArgs);
}