UNPKG

@viewdo/dxp-story-cli

Version:
30 lines (22 loc) 593 B
const fs = require('fs') const path = require('path') const YAML = require('yamljs') function ensureDirectoryExistence(filePath) { var dirname = path.dirname(filePath); if (fs.existsSync(dirname)) { return true; } ensureDirectoryExistence(dirname); fs.mkdirSync(dirname); } module.exports = async (options, next = 0) => { let result = next let { file, output = file.replace('.json', '.yaml') } = options let json_object = YAML.load(file) ensureDirectoryExistence(output) fs.writeFileSync(output, JSON.stringify(json_object, null, 2)) return result }