UNPKG

@visulima/fs

Version:

Human friendly file system utilities for Node.js

30 lines (26 loc) 1.13 kB
'use strict'; const yaml = require('yaml'); const writeFileSync = require('./writeFileSync-DzXhx1pF.cjs'); 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 = yaml.stringify(data, effectiveReplacer, space ?? stringifyOptions); writeFileSync(path, content, stringifyOptions); } __name(writeYamlSync, "writeYamlSync"); module.exports = writeYamlSync;