2024-03-20 09:26:52 +01:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.FileUtils = void 0;
|
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("node:path");
|
2024-03-20 19:35:24 +01:00
|
|
|
const fs_1 = require("fs");
|
2024-03-20 09:26:52 +01:00
|
|
|
class FileUtils {
|
|
|
|
static listFilesInDirectory(directory) {
|
|
|
|
if (fs.lstatSync(directory).isDirectory()) {
|
|
|
|
return fs.readdirSync(directory).map(fileName => path.join(directory, fileName));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
2024-03-20 19:35:24 +01:00
|
|
|
static prepareFileForWriting(file) {
|
|
|
|
const parentDirectory = path.dirname(file);
|
|
|
|
if (!fs.existsSync(parentDirectory)) {
|
|
|
|
(0, fs_1.mkdirSync)(parentDirectory, { recursive: true });
|
|
|
|
}
|
|
|
|
}
|
2024-03-21 08:43:28 +01:00
|
|
|
static removeFiles(files) {
|
|
|
|
files.forEach(file => {
|
|
|
|
if (fs.lstatSync(file).isDirectory()) {
|
|
|
|
fs.rmdirSync(file);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fs.unlinkSync(file);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-03-20 09:26:52 +01:00
|
|
|
}
|
|
|
|
exports.FileUtils = FileUtils;
|
|
|
|
//# sourceMappingURL=FileUtils.js.map
|