UNPKG

1.47 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 update(rootNames, inDir, outDir) {
12 let isOutputChanged = false; // improve this
13 if (!rootNames || !rootNames.length) {
14 if (this.files.length) {
15 isOutputChanged = true;
16 }
17 this.files = [];
18 }
19 else {
20 // remove output files that was deleted
21 this.files.forEach((v, i) => {
22 if (!rootNames.includes(v.rootName)) {
23 isOutputChanged = true;
24 this.files.splice(i, 1);
25 }
26 });
27 // add new rootNames
28 rootNames.forEach(rootName => {
29 const ePath = rootName.replace(/(.ts)$/, ".js");
30 const outPath = path_1.default.join(outDir, path_1.default.relative(inDir || process.cwd(), ePath));
31 if (!this.files.find(f => f.path === outPath)) {
32 this.files.push({ path: outPath, rootName });
33 }
34 });
35 }
36 return isOutputChanged;
37 }
38}
39exports.CompilerOutRootFiles = CompilerOutRootFiles;