UNPKG

@visulima/fs

Version:

Human friendly file system utilities for Node.js

28 lines (25 loc) 1.09 kB
import { stringify } from 'yaml'; import writeFile from './writeFile-BZ4JBQxc.mjs'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); async function writeYaml(path, data, replacer, options) { let stringifyOptions; let effectiveReplacer; let space; if (typeof replacer === "object" && replacer !== null && !Array.isArray(replacer) && typeof replacer !== "function") { stringifyOptions = replacer; effectiveReplacer = stringifyOptions.replacer; space = stringifyOptions.space; } else if (typeof options === "object" && options !== null) { stringifyOptions = options; effectiveReplacer = replacer; space = stringifyOptions.space ?? (typeof options === "number" || typeof options === "string" ? options : void 0); } else { effectiveReplacer = replacer; space = options; } const content = stringify(data, effectiveReplacer, space ?? stringifyOptions); await writeFile(path, content, stringifyOptions); } __name(writeYaml, "writeYaml"); export { writeYaml as default };