You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.0 KiB

  1. // Generated by CoffeeScript 1.6.2
  2. var DocPad, action, docpadConfig, getArgument;
  3. DocPad = require(__dirname + '/../lib/docpad');
  4. getArgument = function(name, value, defaultValue) {
  5. var argumentIndex, result;
  6. if (value == null) {
  7. value = null;
  8. }
  9. if (defaultValue == null) {
  10. defaultValue = null;
  11. }
  12. result = defaultValue;
  13. argumentIndex = process.argv.indexOf("--" + name);
  14. if (argumentIndex !== -1) {
  15. result = value != null ? value : process.argv[argumentIndex + 1];
  16. }
  17. return result;
  18. };
  19. action = (getArgument('action', null, 'generate') + ' ' + getArgument('watch', 'watch', '')).trim();
  20. docpadConfig = {};
  21. docpadConfig.rootPath = getArgument('rootPath', null, process.cwd());
  22. docpadConfig.outPath = getArgument('outPath', null, docpadConfig.rootPath + '/out');
  23. docpadConfig.srcPath = getArgument('srcPath', null, docpadConfig.rootPath + '/src');
  24. docpadConfig.documentsPaths = (function() {
  25. var documentsPath;
  26. documentsPath = getArgument('documentsPath');
  27. if (documentsPath != null) {
  28. if (documentsPath === 'auto') {
  29. documentsPath = docpadConfig.srcPath;
  30. }
  31. } else {
  32. documentsPath = docpadConfig.srcPath + '/documents';
  33. }
  34. return [documentsPath];
  35. })();
  36. docpadConfig.port = (function() {
  37. var port;
  38. port = getArgument('port');
  39. if (port && isNaN(port) === false) {
  40. port = parseInt(port, 10);
  41. }
  42. return port;
  43. })();
  44. docpadConfig.renderSingleExtensions = (function() {
  45. var renderSingleExtensions;
  46. renderSingleExtensions = getArgument('renderSingleExtensions', null, 'auto');
  47. if (renderSingleExtensions === 'true' || renderSingleExtensions === 'yes') {
  48. renderSingleExtensions = true;
  49. } else if (renderSingleExtensions === 'false' || renderSingleExtensions === 'no') {
  50. renderSingleExtensions = false;
  51. }
  52. return renderSingleExtensions;
  53. })();
  54. DocPad.createInstance(docpadConfig, function(err, docpad) {
  55. if (err) {
  56. return console.log(err.stack);
  57. }
  58. return docpad.action(action, function(err) {
  59. if (err) {
  60. return console.log(err.stack);
  61. }
  62. return console.log('OK');
  63. });
  64. });