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.

45 lines
1014 B

  1. // Generated by CoffeeScript 1.6.3
  2. var DocPad, action, docpadConfig, getArgument;
  3. DocPad = require('../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, 'server generate');
  20. docpadConfig = {};
  21. docpadConfig.port = (function() {
  22. var port;
  23. port = getArgument('port');
  24. if (port && isNaN(port) === false) {
  25. port = parseInt(port, 10);
  26. }
  27. return port;
  28. })();
  29. DocPad.createInstance(docpadConfig, function(err, docpad) {
  30. if (err) {
  31. return console.log(err.stack);
  32. }
  33. return docpad.action(action, function(err) {
  34. if (err) {
  35. return console.log(err.stack);
  36. }
  37. return console.log('OK');
  38. });
  39. });