UNPKG

894 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const load_config_1 = require("./load-config");
4const castArray = (input) => {
5 if (input === undefined)
6 return [];
7 return Array.isArray(input) ? input : [input];
8};
9function command(args, opts = {}) {
10 return {
11 async run(ctx) {
12 // eslint-disable-next-line require-atomic-updates
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 // eslint-disable-next-line require-atomic-updates
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}
24exports.command = command;