UNPKG

2.86 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.NullTree = exports.NullTreeDirEntry = exports.CannotCreateFileException = void 0;
11const core_1 = require("@angular-devkit/core");
12const exception_1 = require("../exception/exception");
13const interface_1 = require("./interface");
14const recorder_1 = require("./recorder");
15class CannotCreateFileException extends core_1.BaseException {
16 constructor(path) {
17 super(`Cannot create file "${path}".`);
18 }
19}
20exports.CannotCreateFileException = CannotCreateFileException;
21class NullTreeDirEntry {
22 constructor(path) {
23 this.path = path;
24 this.subdirs = [];
25 this.subfiles = [];
26 }
27 get parent() {
28 return this.path == '/' ? null : new NullTreeDirEntry((0, core_1.dirname)(this.path));
29 }
30 dir(name) {
31 return new NullTreeDirEntry((0, core_1.join)(this.path, name));
32 }
33 file(_name) {
34 return null;
35 }
36 visit() { }
37}
38exports.NullTreeDirEntry = NullTreeDirEntry;
39class NullTree {
40 constructor() {
41 this.root = new NullTreeDirEntry((0, core_1.normalize)('/'));
42 }
43 [interface_1.TreeSymbol]() {
44 return this;
45 }
46 branch() {
47 return new NullTree();
48 }
49 merge(_other, _strategy) { }
50 // Simple readonly file system operations.
51 exists(_path) {
52 return false;
53 }
54 read(_path) {
55 return null;
56 }
57 readText(path) {
58 throw new exception_1.FileDoesNotExistException(path);
59 }
60 readJson(path) {
61 throw new exception_1.FileDoesNotExistException(path);
62 }
63 get(_path) {
64 return null;
65 }
66 getDir(path) {
67 return new NullTreeDirEntry((0, core_1.normalize)('/' + path));
68 }
69 visit() { }
70 // Change content of host files.
71 beginUpdate(path) {
72 throw new exception_1.FileDoesNotExistException(path);
73 }
74 commitUpdate(record) {
75 throw new exception_1.FileDoesNotExistException(record instanceof recorder_1.UpdateRecorderBase ? record.path : '<unknown>');
76 }
77 // Change structure of the host.
78 copy(path, _to) {
79 throw new exception_1.FileDoesNotExistException(path);
80 }
81 delete(path) {
82 throw new exception_1.FileDoesNotExistException(path);
83 }
84 create(path, _content) {
85 throw new CannotCreateFileException(path);
86 }
87 rename(path, _to) {
88 throw new exception_1.FileDoesNotExistException(path);
89 }
90 overwrite(path, _content) {
91 throw new exception_1.FileDoesNotExistException(path);
92 }
93 apply(_action, _strategy) { }
94 get actions() {
95 return [];
96 }
97}
98exports.NullTree = NullTree;