@feflow/cli
Version:
A front-end flow tool.
25 lines (19 loc) • 458 B
text/typescript
import fs from 'fs';
import yaml from 'js-yaml';
export function parseYaml(path: string) {
let config;
if (fs.existsSync(path)) {
config = yaml.safeLoad(fs.readFileSync(path, 'utf8'));
}
return config;
}
export function safeDump(obj: object, path: string) {
const doc = yaml.safeDump(obj, {
styles: {
'!!null': 'canonical',
},
sortKeys: true,
skipInvalid: true,
});
return fs.writeFileSync(path, doc, 'utf-8');
}