mstr-viz
Version:
A new dev tool for creating custom visualizations
18 lines (16 loc) • 481 B
JavaScript
const fs = require('fs-extra');
const path = require('path');
const mkdirp = require('mkdirp');
/**
* Write data into a file, and if the path doesn't exist, create it first.
* @param filepath
* @param data
* @param [options]
*/
module.exports = (filepath, data, options) => {
if (typeof filepath !== 'string') {
throw new TypeError('expected filepath to be a string');
}
mkdirp.sync(path.dirname(filepath), options);
fs.writeFileSync(filepath, data, options);
};