UNPKG

1.91 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12exports.createHost = void 0;
13const core_1 = require("@angular-devkit/core");
14const schematics_1 = require("@angular-devkit/schematics");
15function createHost(tree) {
16 return {
17 readFile(path) {
18 return __awaiter(this, void 0, void 0, function* () {
19 const data = tree.read(path);
20 if (!data) {
21 throw new schematics_1.SchematicsException('File not found.');
22 }
23 return core_1.virtualFs.fileBufferToString(data);
24 });
25 },
26 writeFile(path, data) {
27 return __awaiter(this, void 0, void 0, function* () {
28 return tree.overwrite(path, data);
29 });
30 },
31 isDirectory(path) {
32 return __awaiter(this, void 0, void 0, function* () {
33 return !tree.exists(path) && tree.getDir(path).subfiles.length > 0;
34 });
35 },
36 isFile(path) {
37 return __awaiter(this, void 0, void 0, function* () {
38 return tree.exists(path);
39 });
40 }
41 };
42}
43exports.createHost = createHost;
44//# sourceMappingURL=utils.js.map
\No newline at end of file