1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.listModules = void 0;
|
4 | const glob = require("glob");
|
5 | const path = require("path");
|
6 | const utils_1 = require("./utils");
|
7 |
|
8 | const nameExpr = /(.*)\..*/i;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function _listModules(globPattern, opts) {
|
25 | opts = Object.assign({ cwd: process.cwd(), glob: glob.sync }, opts);
|
26 | let patternOpts = null;
|
27 | if (globPattern instanceof Array) {
|
28 | patternOpts = globPattern[1];
|
29 | globPattern = globPattern[0];
|
30 | }
|
31 | const result = opts.glob(globPattern, { cwd: opts.cwd });
|
32 | const mapped = result.map((p) => ({
|
33 | name: nameExpr.exec(path.basename(p))[1],
|
34 | path: path.resolve(opts.cwd, p),
|
35 | opts: patternOpts,
|
36 | }));
|
37 | return mapped;
|
38 | }
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | function listModules(globPatterns, opts) {
|
55 | if (Array.isArray(globPatterns)) {
|
56 | return utils_1.flatten(globPatterns.map((p) => _listModules(p, opts)));
|
57 | }
|
58 | return _listModules(globPatterns, opts);
|
59 | }
|
60 | exports.listModules = listModules;
|
61 |
|
\ | No newline at end of file |