source: trip-planner-front/node_modules/@angular/compiler-cli/ngcc/src/writing/cleaning/package_cleaner.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 11.9 KB
Line 
1(function (factory) {
2 if (typeof module === "object" && typeof module.exports === "object") {
3 var v = factory(require, exports);
4 if (v !== undefined) module.exports = v;
5 }
6 else if (typeof define === "function" && define.amd) {
7 define("@angular/compiler-cli/ngcc/src/writing/cleaning/package_cleaner", ["require", "exports", "tslib", "@angular/compiler-cli/ngcc/src/packages/build_marker", "@angular/compiler-cli/ngcc/src/writing/cleaning/cleaning_strategies", "@angular/compiler-cli/ngcc/src/writing/cleaning/utils"], factory);
8 }
9})(function (require, exports) {
10 "use strict";
11 Object.defineProperty(exports, "__esModule", { value: true });
12 exports.cleanOutdatedPackages = exports.PackageCleaner = void 0;
13 var tslib_1 = require("tslib");
14 var build_marker_1 = require("@angular/compiler-cli/ngcc/src/packages/build_marker");
15 var cleaning_strategies_1 = require("@angular/compiler-cli/ngcc/src/writing/cleaning/cleaning_strategies");
16 var utils_1 = require("@angular/compiler-cli/ngcc/src/writing/cleaning/utils");
17 /**
18 * A class that can clean ngcc artifacts from a directory.
19 */
20 var PackageCleaner = /** @class */ (function () {
21 function PackageCleaner(fs, cleaners) {
22 this.fs = fs;
23 this.cleaners = cleaners;
24 }
25 /**
26 * Recurse through the file-system cleaning files and directories as determined by the configured
27 * cleaning-strategies.
28 *
29 * @param directory the current directory to clean
30 */
31 PackageCleaner.prototype.clean = function (directory) {
32 var e_1, _a, e_2, _b;
33 var basenames = this.fs.readdir(directory);
34 try {
35 for (var basenames_1 = tslib_1.__values(basenames), basenames_1_1 = basenames_1.next(); !basenames_1_1.done; basenames_1_1 = basenames_1.next()) {
36 var basename = basenames_1_1.value;
37 if (basename === 'node_modules') {
38 continue;
39 }
40 var path = this.fs.resolve(directory, basename);
41 try {
42 for (var _c = (e_2 = void 0, tslib_1.__values(this.cleaners)), _d = _c.next(); !_d.done; _d = _c.next()) {
43 var cleaner = _d.value;
44 if (cleaner.canClean(path, basename)) {
45 cleaner.clean(path, basename);
46 break;
47 }
48 }
49 }
50 catch (e_2_1) { e_2 = { error: e_2_1 }; }
51 finally {
52 try {
53 if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
54 }
55 finally { if (e_2) throw e_2.error; }
56 }
57 // Recurse into subdirectories (note that a cleaner may have removed this path)
58 if (utils_1.isLocalDirectory(this.fs, path)) {
59 this.clean(path);
60 }
61 }
62 }
63 catch (e_1_1) { e_1 = { error: e_1_1 }; }
64 finally {
65 try {
66 if (basenames_1_1 && !basenames_1_1.done && (_a = basenames_1.return)) _a.call(basenames_1);
67 }
68 finally { if (e_1) throw e_1.error; }
69 }
70 };
71 return PackageCleaner;
72 }());
73 exports.PackageCleaner = PackageCleaner;
74 /**
75 * Iterate through the given `entryPoints` identifying the package for each that has at least one
76 * outdated processed format, then cleaning those packages.
77 *
78 * Note that we have to clean entire packages because there is no clear file-system boundary
79 * between entry-points within a package. So if one entry-point is outdated we have to clean
80 * everything within that package.
81 *
82 * @param fileSystem the current file-system
83 * @param entryPoints the entry-points that have been collected for this run of ngcc
84 * @returns true if packages needed to be cleaned.
85 */
86 function cleanOutdatedPackages(fileSystem, entryPoints) {
87 var e_3, _a, e_4, _b;
88 var packagesToClean = new Set();
89 try {
90 for (var entryPoints_1 = tslib_1.__values(entryPoints), entryPoints_1_1 = entryPoints_1.next(); !entryPoints_1_1.done; entryPoints_1_1 = entryPoints_1.next()) {
91 var entryPoint = entryPoints_1_1.value;
92 if (build_marker_1.needsCleaning(entryPoint.packageJson)) {
93 packagesToClean.add(entryPoint.packagePath);
94 }
95 }
96 }
97 catch (e_3_1) { e_3 = { error: e_3_1 }; }
98 finally {
99 try {
100 if (entryPoints_1_1 && !entryPoints_1_1.done && (_a = entryPoints_1.return)) _a.call(entryPoints_1);
101 }
102 finally { if (e_3) throw e_3.error; }
103 }
104 var cleaner = new PackageCleaner(fileSystem, [
105 new cleaning_strategies_1.PackageJsonCleaner(fileSystem),
106 new cleaning_strategies_1.NgccDirectoryCleaner(fileSystem),
107 new cleaning_strategies_1.BackupFileCleaner(fileSystem),
108 ]);
109 try {
110 for (var packagesToClean_1 = tslib_1.__values(packagesToClean), packagesToClean_1_1 = packagesToClean_1.next(); !packagesToClean_1_1.done; packagesToClean_1_1 = packagesToClean_1.next()) {
111 var packagePath = packagesToClean_1_1.value;
112 cleaner.clean(packagePath);
113 }
114 }
115 catch (e_4_1) { e_4 = { error: e_4_1 }; }
116 finally {
117 try {
118 if (packagesToClean_1_1 && !packagesToClean_1_1.done && (_b = packagesToClean_1.return)) _b.call(packagesToClean_1);
119 }
120 finally { if (e_4) throw e_4.error; }
121 }
122 return packagesToClean.size > 0;
123 }
124 exports.cleanOutdatedPackages = cleanOutdatedPackages;
125});
126//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFja2FnZV9jbGVhbmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXItY2xpL25nY2Mvc3JjL3dyaXRpbmcvY2xlYW5pbmcvcGFja2FnZV9jbGVhbmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7SUFRQSxxRkFBMEQ7SUFHMUQsMkdBQW9IO0lBQ3BILCtFQUF5QztJQUV6Qzs7T0FFRztJQUNIO1FBQ0Usd0JBQW9CLEVBQXNCLEVBQVUsUUFBNEI7WUFBNUQsT0FBRSxHQUFGLEVBQUUsQ0FBb0I7WUFBVSxhQUFRLEdBQVIsUUFBUSxDQUFvQjtRQUFHLENBQUM7UUFFcEY7Ozs7O1dBS0c7UUFDSCw4QkFBSyxHQUFMLFVBQU0sU0FBeUI7O1lBQzdCLElBQU0sU0FBUyxHQUFHLElBQUksQ0FBQyxFQUFFLENBQUMsT0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