import { writeFileSync, existsSync } from 'fs' import * as path from 'path' import * as mkdirp from 'mkdirp' export default function (location, output) { const fullpath = path.join(location) const folderPath = fullpath.substr(0, fullpath.lastIndexOf('/')) const dir = folderPath if (!existsSync(dir)) { mkdirp.sync(folderPath) } writeFileSync(fullpath, output, { flag: 'wx' }) }