fetch-content.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const chalk = require('chalk');
  2. var fetch_projects = require('./fetch-scripts/fetch-projects');
  3. var hasArg = function(arg){
  4. for (let i = 0; i < process.argv.length; i++) {
  5. if (arg == process.argv[i]) return true;
  6. }
  7. return false;
  8. }
  9. var isVerbose = function(){
  10. if(hasArg('-v') || hasArg('--verbose')) return true;
  11. else return false;
  12. }
  13. if(hasArg('help') || hasArg('-h')) {
  14. console.log();
  15. console.log('Usage: ' + chalk.bgWhite.black('node fetch-content <command>'));
  16. console.log();
  17. console.log('Copy files from codex to build the website content.');
  18. console.log();
  19. console.log(chalk.bold(' Command Description'));
  20. console.log(' projects Copy projects from Codex');
  21. console.log(' posts Copy blog posts from Codex');
  22. console.log(' -v, --verbose Log all output');
  23. console.log();
  24. console.log();
  25. return;
  26. }
  27. if(hasArg('projects')) {
  28. if(isVerbose()) console.log('Copying projects from Codex');
  29. fetch_projects();
  30. return;
  31. }
  32. if(hasArg('posts')) {
  33. if(isVerbose()) console.log('Copying blog posts from Codex');
  34. return;
  35. }
  36. if(isVerbose()) console.log('Copying projects and blog posts from Codex');
  37. fetch_projects();