add fileUnlink sync helper
This commit is contained in:
parent
3fa4e575f8
commit
960e73f467
1 changed files with 19 additions and 0 deletions
19
helpers/fileUnlink.js
Normal file
19
helpers/fileUnlink.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
import fs from "fs";
|
||||
|
||||
const fileUnlink = (filePath) => {
|
||||
try {
|
||||
if (fs.existsSync(filePath)) {
|
||||
fs.unlinkSync(filePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (e){
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export {
|
||||
fileUnlink as default,
|
||||
fileUnlink
|
||||
}
|
Loading…
Add table
Reference in a new issue