lilacs
Version:
A web frontend building tool for teamwork, with automaticly compiling, merging, minifying, syncing files to server, supporting distributed servers, ensuring css or html files' inline reference with correct absolute path, and more.
43 lines (35 loc) • 805 B
JavaScript
;
var fs = require('fs');
var fileUtil = {
/**
* check directory is exist
*
* @param dirPath
* @returns {boolean}
*/
dirExist: (dirPath) => {
try {
var stat = fs.statSync(dirPath);
return stat.isDirectory();
} catch (err) {
if (err.code === 'ENOENT') return !1;
else throw new Error(err);
}
},
/**
* check file is exist
*
* @param filePath
* @returns {boolean}
*/
fileExist: (filePath) => {
try {
var stat = fs.statSync(filePath);
return stat.isFile();
} catch (err) {
if (err.code === 'ENOENT') return !1;
else throw new Error(err);
}
}
};
module.exports = fileUtil;