UNPKG

@catladder/cli

Version:

Panter cli tool for cloud CI/CD and DevOps

40 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.writeYamlfile = exports.yamlStringifyOptions = exports.writeGeneratedFile = exports.getAutoGeneratedHeader = void 0; const promises_1 = require("fs/promises"); const yaml_1 = require("yaml"); const getAutoGeneratedHeader = (commentChar) => { return [ "-------------------------------------------------", `🐱 🔨 This file is generated by catladder`, `🚨 Do not edit this file manually 🚨`, "-------------------------------------------------", ] .map((line) => `${commentChar} ${line}`) .join("\n") .concat("\n"); }; exports.getAutoGeneratedHeader = getAutoGeneratedHeader; const writeGeneratedFile = async (path, content, { commentChar, }) => { await (0, promises_1.writeFile)(path, // need to spread out the jobs, forgot why [(0, exports.getAutoGeneratedHeader)(commentChar), content].join("\n"), { encoding: "utf-8", }); }; exports.writeGeneratedFile = writeGeneratedFile; exports.yamlStringifyOptions = { // prevents colapsing long command statements into multiple lines lineWidth: 0, // represent multi line commands as single line json strings doubleQuotedAsJSON: true, // Better readability when bash commands most often use double quotes singleQuote: true, }; const writeYamlfile = async (path, data) => { await (0, exports.writeGeneratedFile)(path, (0, yaml_1.stringify)(data, exports.yamlStringifyOptions), { commentChar: "#", }); }; exports.writeYamlfile = writeYamlfile; //# sourceMappingURL=writeFiles.js.map