var fs = require('fs') const chalk = require('chalk'); const logSymbols = require('log-symbols'); module.exports.copyFile = function(original_path, destination_path){ try { fs.copyFileSync(original_path, destination_path); return true; } catch (err){ if(err.code == 'ENOENT'){ if(global.isVerbose) { console.log(logSymbols.error, chalk.red(`ERROR: File not found: \'${original_path}\'`)) } } else { if(global.isVerbose) console.log(logSymbols.error, chalk.red('An error occured: ')); if(global.isVerbose) console.log(err); } return false; } } module.exports.getDirectories = function(source) { return fs.readdirSync(source, { withFileTypes: true }) .filter(item => item.isDirectory()) .map(item => item.name); } module.exports.fileExists = function(path){ if (fs.existsSync(path)) return true; else return false; } module.exports.createDirectory = function(dir){ if (!fs.existsSync(dir)){ fs.mkdirSync(dir); } }