1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const load_config_1 = require("./load-config");
|
4 | const castArray = (input) => {
|
5 | if (input === undefined)
|
6 | return [];
|
7 | return Array.isArray(input) ? input : [input];
|
8 | };
|
9 | function command(args, opts = {}) {
|
10 | return {
|
11 | async run(ctx) {
|
12 |
|
13 | if (!ctx.config || opts.reset)
|
14 | ctx.config = await load_config_1.loadConfig(opts).run({});
|
15 | args = castArray(args);
|
16 | const [id, ...extra] = args;
|
17 |
|
18 | ctx.expectation = ctx.expectation || `runs ${args.join(' ')}`;
|
19 | await ctx.config.runHook('init', { id, argv: extra });
|
20 | await ctx.config.runCommand(id, extra);
|
21 | },
|
22 | };
|
23 | }
|
24 | exports.command = command;
|