UNPKG

1.92 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.prepare = void 0;
4var tslib_1 = require("tslib");
5var common_1 = require("../common");
6function prepare(args) {
7 if (args === void 0) { args = {}; }
8 return tslib_1.__awaiter(this, void 0, void 0, function () {
9 var silent, log, dir, _a, cmds, res, error_1;
10 return tslib_1.__generator(this, function (_b) {
11 switch (_b.label) {
12 case 0:
13 silent = args.silent;
14 log = common_1.getLog(args.silent);
15 _a = args.dir;
16 if (_a) return [3, 2];
17 return [4, common_1.paths.closestParentOf('package.json')];
18 case 1:
19 _a = (_b.sent());
20 _b.label = 2;
21 case 2:
22 dir = _a;
23 if (!dir) {
24 return [2, common_1.result.fail("A module root with [package.json] could not be found.")];
25 }
26 _b.label = 3;
27 case 3:
28 _b.trys.push([3, 5, , 6]);
29 log.info();
30 cmds = ['yarn build', 'yarn lint', 'yarn test'];
31 return [4, common_1.exec.cmd.runList(cmds, {
32 cwd: common_1.fs.resolve(dir),
33 silent: silent,
34 concurrent: true,
35 exitOnError: false,
36 })];
37 case 4:
38 res = _b.sent();
39 res.errors.log({ log: log });
40 return [2, res];
41 case 5:
42 error_1 = _b.sent();
43 return [2, common_1.result.fail(error_1)];
44 case 6: return [2];
45 }
46 });
47 });
48}
49exports.prepare = prepare;