44 lines
No EOL
1.9 KiB
JavaScript
44 lines
No EOL
1.9 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.createHost = void 0;
|
|
const core_1 = require("@angular-devkit/core");
|
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
function createHost(tree) {
|
|
return {
|
|
readFile(path) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const data = tree.read(path);
|
|
if (!data) {
|
|
throw new schematics_1.SchematicsException('File not found.');
|
|
}
|
|
return core_1.virtualFs.fileBufferToString(data);
|
|
});
|
|
},
|
|
writeFile(path, data) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return tree.overwrite(path, data);
|
|
});
|
|
},
|
|
isDirectory(path) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return !tree.exists(path) && tree.getDir(path).subfiles.length > 0;
|
|
});
|
|
},
|
|
isFile(path) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return tree.exists(path);
|
|
});
|
|
}
|
|
};
|
|
}
|
|
exports.createHost = createHost;
|
|
//# sourceMappingURL=utils.js.map
|