UNPKG

sandhog

Version:

A virtual Open Source project maintainer

35 lines (34 loc) 1.24 kB
import { generateFunding } from "./chunk-55PDE7QT.js"; import { confirm } from "./chunk-HDJNIELN.js"; import { getContributorsFromPackage } from "./chunk-H3ZAQGMJ.js"; import { CONSTANT } from "./chunk-VYUMLP7D.js"; // src/cli/task/funding/funding-task.ts import path from "crosspath"; async function fundingTask({ pkg, logger, prettier, config, root, fs, yes }) { const contributors = getContributorsFromPackage(pkg); const cocText = await generateFunding({ contributors, config, prettier }); const dir = path.join(root, CONSTANT.githubDirName); const pathFromRoot = path.join(dir, CONSTANT.fundingFilename); const nativeDir = path.native.normalize(dir); const nativePath = path.native.normalize(pathFromRoot); const writePermission = yes || !fs.existsSync(nativePath) || fs.readFileSync(nativePath, "utf8") === cocText || await confirm(`A ${CONSTANT.fundingFilename} file already exists at path: ${nativePath}. Do you wish to overwrite it?`, false); if (writePermission) { if (!fs.existsSync(nativeDir)) { fs.mkdirSync(nativeDir); } logger.info(`Writing '${nativePath}'`); fs.writeFileSync(nativePath, cocText); } } export { fundingTask }; //# sourceMappingURL=funding-task-IBAKCYYM.js.map