detox-allure2-adapter
Version:
Detox adapter for jest-allure2-reporter
41 lines • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RecycleBin = void 0;
const tslib_1 = require("tslib");
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
const node_path_1 = tslib_1.__importDefault(require("node:path"));
class RecycleBin {
_onError;
static _instance;
_files = new Set();
constructor(_onError) {
this._onError = _onError;
}
static instance(onError) {
if (onError) {
this._instance = new RecycleBin(onError);
}
if (!this._instance) {
throw new Error('[detox-allure2-adapter] RecycleBin instance not initialized');
}
return this._instance;
}
add = async (filePath) => {
this._files.add(node_path_1.default.resolve(filePath));
};
delete = async (filePath) => {
try {
await promises_1.default.rm(node_path_1.default.resolve(filePath), { recursive: true, force: true });
this._files.delete(node_path_1.default.resolve(filePath));
}
catch (error) {
return this._onError(error);
}
};
clear = async () => {
await Promise.all([...this._files].map(this.delete));
this._files.clear();
};
}
exports.RecycleBin = RecycleBin;
//# sourceMappingURL=RecycleBin.js.map