Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 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 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.createWorkspaceHost = void 0;
|
---|
11 | const virtual_fs_1 = require("../virtual-fs");
|
---|
12 | function createWorkspaceHost(host) {
|
---|
13 | const workspaceHost = {
|
---|
14 | async readFile(path) {
|
---|
15 | const data = await host.read(virtual_fs_1.normalize(path)).toPromise();
|
---|
16 | return virtual_fs_1.virtualFs.fileBufferToString(data);
|
---|
17 | },
|
---|
18 | async writeFile(path, data) {
|
---|
19 | return host.write(virtual_fs_1.normalize(path), virtual_fs_1.virtualFs.stringToFileBuffer(data)).toPromise();
|
---|
20 | },
|
---|
21 | async isDirectory(path) {
|
---|
22 | try {
|
---|
23 | return await host.isDirectory(virtual_fs_1.normalize(path)).toPromise();
|
---|
24 | }
|
---|
25 | catch {
|
---|
26 | // some hosts throw if path does not exist
|
---|
27 | return false;
|
---|
28 | }
|
---|
29 | },
|
---|
30 | async isFile(path) {
|
---|
31 | try {
|
---|
32 | return await host.isFile(virtual_fs_1.normalize(path)).toPromise();
|
---|
33 | }
|
---|
34 | catch {
|
---|
35 | // some hosts throw if path does not exist
|
---|
36 | return false;
|
---|
37 | }
|
---|
38 | },
|
---|
39 | };
|
---|
40 | return workspaceHost;
|
---|
41 | }
|
---|
42 | exports.createWorkspaceHost = createWorkspaceHost;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.