@softwareventures/maintain-project
Version:
Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited
29 lines • 992 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 writeProjectText(project, path, text) {
const absolutePath = resolve(project.path, path);
return fs.writeFile(absolutePath, text, "utf-8").then(() => success(), (reason) => {
if (hasProperty(reason, "code")) {
if (reason.code === "ENOENT") {
return failure([
{
type: "file-not-found",
path: absolutePath
}
]);
}
else if (reason.code === "EISDIR") {
return failure([
{
type: "file-is-directory",
path: absolutePath
}
]);
}
}
throw reason;
});
}
//# sourceMappingURL=write-text.js.map