cdt-cli
Version:
A simple CLI for creating your projects
25 lines (23 loc) • 589 B
JavaScript
;
const fs = require('fs')
const path = require('path')
/**
* @param { delPath:String } (需要删除文件的地址)
* @param { direct:Boolean } (是否需要处理地址)
*/
function deleteFile(delPath, direct) {
delPath = direct ? delPath : path.join(__dirname, delPath)
try {
/**
* @des 判断文件或文件夹是否存在
*/
if (fs.existsSync(delPath)) {
fs.unlinkSync(delPath);
} else {
console.log('inexistence path:', delPath);
}
} catch (error) {
console.log('del error', error);
}
}
module.exports = deleteFile