UNPKG

sandhog

Version:

A virtual Open Source project maintainer

36 lines (35 loc) 1.2 kB
import { generateReadme } from "./chunk-C3ACRQH5.js"; import "./chunk-4KN5GL56.js"; import "./chunk-GEXBMSSY.js"; import "./chunk-VWKPPDPS.js"; import "./chunk-VZLM7UUV.js"; import { confirm } from "./chunk-HDJNIELN.js"; import "./chunk-H3ZAQGMJ.js"; import { CONSTANT } from "./chunk-VYUMLP7D.js"; // src/cli/task/readme/readme-task.ts import path from "crosspath"; async function readmeTask(options) { const { logger, root, fs, yes } = options; const pathFromRoot = path.join(root, CONSTANT.readmeFilename); const nativePath = path.native.normalize(pathFromRoot); const existingReadme = fs.existsSync(nativePath) ? fs.readFileSync(nativePath, "utf8") : void 0; const readmeText = await generateReadme({ ...options, existingReadme }); const writePermission = yes || !fs.existsSync(nativePath) || fs.readFileSync(nativePath, "utf8") === readmeText || await confirm(`A ${CONSTANT.readmeFilename} file already exists at path: ${nativePath}. Do you wish to overwrite it?`, false); if (writePermission) { logger.info(`Writing '${nativePath}'`); fs.writeFileSync(nativePath, readmeText); } } export { readmeTask }; //# sourceMappingURL=readme-task-2DHDYMEZ.js.map