function toYAML (value) { return yaml.safeDump(value, { noRefs: true }).trim() }
/** * Dumps an object to a YAML file * * @since 3.0.0 * @alias lando.yaml.dump * @param {String} file The path to the file to be loaded * @param {Object} data The object to dump * @return {String} Flename */ dump(file, data = {}) { // Make sure we have a place to store these files mkdirp.sync(path.dirname(file)); // Remove any properties that might be bad and dump data = JSON.parse(JSON.stringify(data)); // And dump fs.writeFileSync(file, yaml.safeDump(data)); // Log and return filename return file; }
function stringify(obj) { return yaml.safeDump(obj); }
/** * Takes in a JavaScript object and outputs a TAP diagnostics string * @param {Object} diagnostic JavaScript object to be embedded as YAML into output. * @returns {string} diagnostics string with YAML embedded - TAP version 13 compliant */ function outputDiagnostics(diagnostic) { const prefix = " "; let output = `${prefix}---\n`; output += prefix + yaml.safeDump(diagnostic).split("\n").join(`\n${prefix}`); output += "...\n"; return output; }
/** * Create a new migration file * @param {object} data * @property {string} up Up SQL * @property {string} down Down SQL * @property {string} specs JSON representation of the currect models */ _createMigrationFile(data) { const filename = helpers.createMigrationFileName() + '.yml'; const filePath = path.join(this.dana.config('baseDir'), 'migrations', filename); return fs.writeFile(filePath, yaml.safeDump(data)).then(() => filePath); }
/** * Writes a configuration file in YAML format. * @param {Object} config The configuration object to write. * @param {string} filePath The filename to write to. * @returns {void} * @private */ function writeYAMLConfigFile(config, filePath) { debug(`Writing YAML config file: ${filePath}`); // lazy load YAML to improve performance when not used const yaml = require("js-yaml"); const content = yaml.safeDump(config, { sortKeys: true }); fs.writeFileSync(filePath, content, "utf8"); }
async function writeResource (config, resources) { const list = { apiVersion: 'v1', kind: 'List', items: resources }; try { // Create the directory await helpers.createDir(`${config.projectLocation}/${DEFAULT_NODESHIFT_RESOURCE_DIR}`); // Now write the json to a file await writeFileAsync(`${config.projectLocation}/${DEFAULT_NODESHIFT_RESOURCE_DIR}/openshift.json`, JSON.stringify(list, null, 2), { encoding: 'utf8' }); // Then write the yaml to a file await writeFileAsync(`${config.projectLocation}/${DEFAULT_NODESHIFT_RESOURCE_DIR}/openshift.yaml`, jsyaml.safeDump(list, { skipInvalid: true }), { encoding: 'utf8' }); logger.info(`openshift.yaml and openshift.json written to ${config.projectLocation}/${DEFAULT_NODESHIFT_RESOURCE_DIR}/`); } catch (err) { logger.error(`error writing files: ${err}`); return Promise.reject(err); } return list; }
const saveConfiguration = (version) => { const config = { version: version, mode: cli['--mode'], user: cli['--user'], } return fs.writeFileAsync(configFile, yaml.safeDump(config)) }
dumpYamlTemplate() { return yaml.safeDump(this.samBuilder.getTemplateObject()); }
YAML.safeDump(example, {indent: 2})); });
const wskManifestString = yaml.safeDump(wskManifestCopy).replace(config.wskManifestPackagePlaceholder, config.owDeploymentPackage)
return yaml.safeDump(fileContent); }) .then((newData) => {
function toYAML (value) { return yaml.safeDump(value, { noRefs: true }).trim() }