UNPKG

@softwareventures/maintain-project

Version:

Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited

22 lines 1.2 kB
import { posix } from "path"; import { anyFn } from "@softwareventures/array"; import { mapNullableFn, mapNullFn } from "@softwareventures/nullable"; import { readIgnore } from "../ignore/read.js"; import { failure, success } from "../result/result.js"; import { readTemplateDirectory } from "./read-directory.js"; import { readTemplateText } from "./read-text.js"; export async function readTemplateIgnore(templateId, path, ...pathSegments) { return readIgnore({ path: posix.join(path, ...pathSegments), basename: path => posix.basename(path), dirname: path => posix.dirname(path), join: (...paths) => posix.join(...paths), readDirectory: async (path) => readTemplateDirectory(templateId, path), readText: async (path) => readTemplateDirectory(templateId, posix.dirname(path)) .then(anyFn(dirent => dirent.name === posix.basename(path) && dirent.isFile())) .then(async (exists) => (exists ? readTemplateText(templateId, path) : null)) .then(mapNullableFn(text => success(text))) .then(mapNullFn(() => failure([{ type: "file-not-found", path }]))) }); } //# sourceMappingURL=read-ignore.js.map