1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | const spec_1 = require("@hayspec/spec");
|
12 | const glob = require("fast-glob");
|
13 | class Runner {
|
14 | constructor(options) {
|
15 | this.results = [];
|
16 | this.options = Object.assign({ cwd: process.cwd(), deep: true, dot: false }, options);
|
17 | }
|
18 | require(...patterns) {
|
19 | return __awaiter(this, void 0, void 0, function* () {
|
20 | const options = Object.assign({ absolute: true }, this.options);
|
21 | const files = yield glob(patterns, options);
|
22 | files.forEach((file) => {
|
23 | this.loadSpec(file);
|
24 | });
|
25 | });
|
26 | }
|
27 | clear() {
|
28 | this.results = [];
|
29 | return this;
|
30 | }
|
31 | loadSpec(file) {
|
32 | const spec = require(file);
|
33 | if (spec instanceof spec_1.Spec) {
|
34 | this.results.push({ file, spec });
|
35 | }
|
36 | else if (spec.default instanceof spec_1.Spec) {
|
37 | this.results.push({ file, spec: spec.default });
|
38 | }
|
39 | }
|
40 | }
|
41 | exports.Runner = Runner;
|
42 |
|
\ | No newline at end of file |