@visulima/fs
Version:
Human friendly file system utilities for Node.js
28 lines (25 loc) • 1.11 kB
JavaScript
import { stringify } from 'yaml';
import writeFileSync from './writeFileSync-Ctw5pNQH.mjs';
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
function writeYamlSync(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);
writeFileSync(path, content, stringifyOptions);
}
__name(writeYamlSync, "writeYamlSync");
export { writeYamlSync as default };