This repository has been archived on 2026-05-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
GitBlog.md/test/test_utils.js
T
2019-06-20 10:07:22 +02:00

19 lines
595 B
JavaScript

const fs = require('fs');
const deleteFolderSync = (path) => {
if (!fs.existsSync(path))
return;
fs.readdirSync(path, {withFileTypes: true}).forEach((item) => {
if (item.isDirectory())
deleteFolderSync(`${path}/${item.name}`);
else
fs.unlinkSync(`${path}/${item.name}`);
});
fs.rmdirSync(path);
};
module.exports = {
deleteFolderSync: deleteFolderSync,
createEmptyDirs: list => list.forEach(path => fs.mkdirSync(path, {recursive: true})),
createEmptyFiles: list => list.forEach(file => fs.writeFileSync(file, '')),
};