1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const path_1 = __importDefault(require("path"));
|
7 | class CompilerOutRootFiles {
|
8 | constructor() {
|
9 | this.files = [];
|
10 | }
|
11 |
|
12 | update(rootNames, inDir, outDir) {
|
13 | let isChanged = false;
|
14 | if (!rootNames || !rootNames.length) {
|
15 | if (this.files.length) {
|
16 | isChanged = true;
|
17 | }
|
18 | this.files = [];
|
19 | }
|
20 | else {
|
21 |
|
22 | this.files.forEach((v, i) => {
|
23 | if (!rootNames.includes(v.rootName)) {
|
24 | isChanged = true;
|
25 | this.files.splice(i, 1);
|
26 | }
|
27 | });
|
28 |
|
29 | rootNames.forEach((rootName) => {
|
30 | const ePath = rootName.replace(/(.ts)$/, ".js");
|
31 | const outPath = path_1.default.join(outDir, path_1.default.relative(inDir, ePath));
|
32 | if (!this.files.find((f) => f.path === outPath)) {
|
33 | isChanged = true;
|
34 | this.files.push({ path: outPath, rootName });
|
35 | }
|
36 | });
|
37 | }
|
38 | return isChanged;
|
39 | }
|
40 | }
|
41 | exports.default = CompilerOutRootFiles;
|