declapract
Version:
A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.
22 lines • 807 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeFileAsync = void 0;
const fs_1 = __importDefault(require("fs"));
const util_1 = __importDefault(require("util"));
const unlink = util_1.default.promisify(fs_1.default.unlink);
const removeFileAsync = async ({ path }) => {
try {
await unlink(path);
}
catch (error) {
// if file doesn't exist, treat as successful no-op (idempotent)
if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
return;
throw error;
}
};
exports.removeFileAsync = removeFileAsync;
//# sourceMappingURL=removeFileAsync.js.map