const _v = require('./variables');

module.exports = () => {
    const funcs = {};

    funcs.isValidOption = (options, targetOption) => _v._.includes(options, targetOption);

    funcs.throwOptionsError = (options) => {
        throw new Error('Invalid choice. Choices: ' + options.join(', '));
    };

    funcs.genericLog = (str, color) => {
        const { $ } = _v;
        $.util.log($.util.colors[color || 'yellow'](str));
    };

    funcs.folderAlreadyPresent = (files, folderName) => _v._.includes(files, folderName);

    funcs.sanitizeProjectName = (projectName) => projectName.toString().replace(/[ ]*,[ ]*|[ ]+/g, ' ');

    funcs.executeSetup = (actionType, projectType, projectName) => {
        const { $, qfs, cwd, baseDir } = _v;

        qfs.list(cwd)
            .then(files => {
                if(funcs.folderAlreadyPresent(files, projectName)) {
                    genericLog(`${$.util.colors.blue(projectName)} folder must not exist during setup. ${$.util.colors.red('terminating...')}`);
                    throw new Error(`${projectName} folder must not exist during setup.`);
                } else {
                    genericLog(`creating ${$.util.colors.blue(projectName)} folder and sub directories`);

                    qfs.copyTree(`${baseDir}/bin/_${actionType}/${projectType}`, `${cwd}/${projectName}`).then(() => {
                        genericLog(`${$.util.colors.blue(projectName)} folder created ${$.util.colors.green('successfully')}`);
                    });
                }
            });
    };

    return funcs;
};
@@ -875,32 +875,38 @@
                 
+funcs.
 genericLog(%60$%7B$.
@@ -1142,32 +1142,38 @@
                 
+funcs.
 genericLog(%60crea
@@ -1386,16 +1386,22 @@
         
+funcs.
 genericL
@@ -1538,16 +1538,107 @@
       %7D%0A
+            %7D)%0A            .catch((err) =%3E %7B%0A                funcs.genericLog(err, 'red');%0A
         

fix logging err