UNPKG

1.5 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const path_1 = __importDefault(require("path"));
7class CompilerOutRootFiles {
8 constructor() {
9 this.files = [];
10 }
11 /** Returns true if list of rootNames is changed */
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 // remove output files that was deleted
22 this.files.forEach((v, i) => {
23 if (!rootNames.includes(v.rootName)) {
24 isChanged = true;
25 this.files.splice(i, 1);
26 }
27 });
28 // add new rootNames
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}
41exports.default = CompilerOutRootFiles;