source: trip-planner-front/node_modules/@angular/compiler-cli/ngcc/src/writing/cleaning/cleaning_strategies.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: 9.5 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/cleaning_strategies", ["require", "exports", "@angular/compiler-cli/src/ngtsc/file_system", "@angular/compiler-cli/ngcc/src/packages/build_marker", "@angular/compiler-cli/ngcc/src/writing/in_place_file_writer", "@angular/compiler-cli/ngcc/src/writing/new_entry_point_file_writer", "@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.BackupFileCleaner = exports.NgccDirectoryCleaner = exports.PackageJsonCleaner = void 0;
13 /**
14 * @license
15 * Copyright Google LLC All Rights Reserved.
16 *
17 * Use of this source code is governed by an MIT-style license that can be
18 * found in the LICENSE file at https://angular.io/license
19 */
20 var file_system_1 = require("@angular/compiler-cli/src/ngtsc/file_system");
21 var build_marker_1 = require("@angular/compiler-cli/ngcc/src/packages/build_marker");
22 var in_place_file_writer_1 = require("@angular/compiler-cli/ngcc/src/writing/in_place_file_writer");
23 var new_entry_point_file_writer_1 = require("@angular/compiler-cli/ngcc/src/writing/new_entry_point_file_writer");
24 var utils_1 = require("@angular/compiler-cli/ngcc/src/writing/cleaning/utils");
25 /**
26 * A CleaningStrategy that reverts changes to package.json files by removing the build marker and
27 * other properties.
28 */
29 var PackageJsonCleaner = /** @class */ (function () {
30 function PackageJsonCleaner(fs) {
31 this.fs = fs;
32 }
33 PackageJsonCleaner.prototype.canClean = function (_path, basename) {
34 return basename === 'package.json';
35 };
36 PackageJsonCleaner.prototype.clean = function (path, _basename) {
37 var packageJson = JSON.parse(this.fs.readFile(path));
38 if (build_marker_1.cleanPackageJson(packageJson)) {
39 this.fs.writeFile(path, JSON.stringify(packageJson, null, 2) + "\n");
40 }
41 };
42 return PackageJsonCleaner;
43 }());
44 exports.PackageJsonCleaner = PackageJsonCleaner;
45 /**
46 * A CleaningStrategy that removes the extra directory containing generated entry-point formats.
47 */
48 var NgccDirectoryCleaner = /** @class */ (function () {
49 function NgccDirectoryCleaner(fs) {
50 this.fs = fs;
51 }
52 NgccDirectoryCleaner.prototype.canClean = function (path, basename) {
53 return basename === new_entry_point_file_writer_1.NGCC_DIRECTORY && utils_1.isLocalDirectory(this.fs, path);
54 };
55 NgccDirectoryCleaner.prototype.clean = function (path, _basename) {
56 this.fs.removeDeep(path);
57 };
58 return NgccDirectoryCleaner;
59 }());
60 exports.NgccDirectoryCleaner = NgccDirectoryCleaner;
61 /**
62 * A CleaningStrategy that reverts files that were overwritten and removes the backup files that
63 * ngcc created.
64 */
65 var BackupFileCleaner = /** @class */ (function () {
66 function BackupFileCleaner(fs) {
67 this.fs = fs;
68 }
69 BackupFileCleaner.prototype.canClean = function (path, basename) {
70 return this.fs.extname(basename) === in_place_file_writer_1.NGCC_BACKUP_EXTENSION &&
71 this.fs.exists(file_system_1.absoluteFrom(path.replace(in_place_file_writer_1.NGCC_BACKUP_EXTENSION, '')));
72 };
73 BackupFileCleaner.prototype.clean = function (path, _basename) {
74 this.fs.moveFile(path, file_system_1.absoluteFrom(path.replace(in_place_file_writer_1.NGCC_BACKUP_EXTENSION, '')));
75 };
76 return BackupFileCleaner;
77 }());
78 exports.BackupFileCleaner = BackupFileCleaner;
79});
80//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xlYW5pbmdfc3RyYXRlZ2llcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyLWNsaS9uZ2NjL3NyYy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