elm-pages-v3-beta/generator/src/file-helpers.js
2020-10-30 10:27:33 -07:00

17 lines
360 B
JavaScript

const fs = require("fs");
module.exports = { ensureDirSync, deleteIfExists };
function ensureDirSync(dirpath) {
try {
fs.mkdirSync(dirpath, { recursive: true });
} catch (err) {
if (err.code !== "EEXIST") throw err;
}
}
function deleteIfExists(/** @type string */ filePath) {
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
}
}