mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-01 16:36:19 +03:00
17 lines
360 B
JavaScript
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);
|
|
}
|
|
}
|