source: trip-planner-front/node_modules/@angular/cdk/schematics/update-tool/utils/virtual-host.mjs

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: 10.5 KB
Line 
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.createFileSystemCompilerHost = exports.FileSystemHost = void 0;
11const ts = require("typescript");
12/**
13 * Implementation of a TypeScript parse config host that relies fully on
14 * a given virtual file system.
15 */
16class FileSystemHost {
17 constructor(_fileSystem) {
18 this._fileSystem = _fileSystem;
19 this.useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
20 }
21 fileExists(path) {
22 return this._fileSystem.fileExists(this._fileSystem.resolve(path));
23 }
24 readFile(path) {
25 const content = this._fileSystem.read(this._fileSystem.resolve(path));
26 if (content === null) {
27 return undefined;
28 }
29 // Strip BOM as otherwise TSC methods (e.g. "getWidth") will return an offset which
30 // which breaks the CLI UpdateRecorder. https://github.com/angular/angular/pull/30719
31 return content.replace(/^\uFEFF/, '');
32 }
33 readDirectory(rootDir, extensions, excludes, includes, depth) {
34 if (ts.matchFiles === undefined) {
35 throw Error('Unable to read directory in virtual file system host. This means that ' +
36 'TypeScript changed its file matching internals.\n\nPlease consider downgrading your ' +
37 'TypeScript version, and report an issue in the Angular Components repository.');
38 }
39 return ts.matchFiles(rootDir, extensions, extensions, includes, this.useCaseSensitiveFileNames, '/', depth, p => this._getFileSystemEntries(p), p => this._fileSystem.resolve(p));
40 }
41 _getFileSystemEntries(path) {
42 return this._fileSystem.readDirectory(this._fileSystem.resolve(path));
43 }
44}
45exports.FileSystemHost = FileSystemHost;
46/**
47 * Creates a TypeScript compiler host that fully relies fully on the given
48 * virtual file system. i.e. no interactions with the working directory.
49 */
50function createFileSystemCompilerHost(options, fileSystem) {
51 const host = ts.createCompilerHost(options, true);
52 const virtualHost = new FileSystemHost(fileSystem);
53 host.readFile = virtualHost.readFile.bind(virtualHost);
54 host.readDirectory = virtualHost.readDirectory.bind(virtualHost);
55 host.fileExists = virtualHost.fileExists.bind(virtualHost);
56 host.directoryExists = (dirPath) => fileSystem.directoryExists(fileSystem.resolve(dirPath));
57 host.getCurrentDirectory = () => '/';
58 host.getCanonicalFileName = p => fileSystem.resolve(p);
59 return host;
60}
61exports.createFileSystemCompilerHost = createFileSystemCompilerHost;
62//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmlydHVhbC1ob3N0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9zY2hlbWF0aWNzL3VwZGF0ZS10b29sL3V0aWxzL3ZpcnR1YWwtaG9zdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7OztHQU1HOzs7QUFFSCxpQ0FBaUM7QUF3QmpDOzs7R0FHRztBQUNILE1BQWEsY0FBYztJQUd6QixZQUFvQixXQUF1QjtRQUF2QixnQkFBVyxHQUFYLFdBQVcsQ0FBWTtRQUYzQyw4QkFBeUIsR0FBRyxFQUFFLENBQUMsR0FBRyxDQUFDLHlCQUF5QixDQUFDO0lBRWYsQ0FBQztJQUUvQyxVQUFVLENBQUMsSUFBWTtRQUNyQixPQUFPLElBQUksQ0FBQyxXQUFXLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7SUFDckUsQ0FBQztJQUVELFFBQVEsQ0FBQyxJQUFZO1FBQ25CLE1BQU0sT0FBTyxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7UUFDdEU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