@softwareventures/maintain-project
Version:
Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited
18 lines • 704 B
JavaScript
import { promises as fs } from "fs";
import { resolve } from "path";
import { hasProperty } from "unknown";
import { failure, success } from "../result/result.js";
export async function readProjectText(project, path) {
return fs.readFile(resolve(project.path, path), "utf-8").then(text => success(text), (reason) => {
if (hasProperty(reason, "code")) {
if (reason.code === "ENOENT") {
return failure([{ type: "file-not-found", path }]);
}
else if (reason.code === "EISDIR") {
return failure([{ type: "file-is-directory", path }]);
}
}
throw reason;
});
}
//# sourceMappingURL=read-text.js.map