projeto-hit/TEST_SERVER1/api/helpers/createDir.js

22 lines
454 B
JavaScript

const fs = require('fs');
function createDir(dir) {
// create new directory
try {
// check if directory already exists
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
console.log("Directory is created.");
} else {
console.log("Directory already exists.");
}
} catch (err) {
console.log(err);
return false
}
return true
}
module.exports = createDir;