const chalk = require('chalk'); var fetch_projects = require('./fetch-scripts/fetch-projects'); var hasArg = function(arg){ for (let i = 0; i < process.argv.length; i++) { if (arg == process.argv[i]) return true; } return false; } var isVerbose = function(){ if(hasArg('-v') || hasArg('--verbose')) { global.isVerbose = true; return true; } else { global.isVerbose = false; return false; } } if(hasArg('help') || hasArg('-h')) { console.log(); console.log('Usage: ' + chalk.bgWhite.black('node fetch-content ')); console.log(); console.log('Copy files from codex to build the website content.'); console.log(); console.log(chalk.bold(' Command Description')); console.log(' projects Copy projects from Codex'); console.log(' posts Copy blog posts from Codex'); console.log(' test Test requirements for all projects'); console.log(' test Test requirements for a specific project'); console.log(' -v, --verbose Log all output'); console.log(); console.log(); return; } if(hasArg('test')){ if(isVerbose()) console.log('Checking requirements:'); var query = "" for (let i = 3; i < process.argv.length; i++) { if (process.argv[i] != '-v' && process.argv[i] != '--verbose' ) query += process.argv[i] + " "; } if(query != '') global.isVerbose = true; fetch_projects.showRequirements(query.replace(/\s+$/, '')) return; } if(hasArg('projects')) { if(isVerbose()) console.log('Copying projects from Codex'); fetch_projects.all(); return; } if(hasArg('posts')) { if(isVerbose()) console.log('Copying blog posts from Codex'); return; } if(isVerbose()) console.log('Copying projects and blog posts from Codex'); fetch_projects.all();