.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. // Generated by CoffeeScript 1.6.3
  2. var APP, BIN, BROWSERIFY, CAKE, COFFEE, DOCPAD, EXT, NODE, NPM, OUT, SRC, WINDOWS, bench, browserify, clean, compile, exec, finish, install, pathUtil, reset, safe, setup, spawn, test, watch, _ref;
  3. WINDOWS = process.platform.indexOf('win') === 0;
  4. NODE = process.execPath;
  5. NPM = WINDOWS ? process.execPath.replace('node.exe', 'npm.cmd') : 'npm';
  6. EXT = (WINDOWS ? '.cmd' : '');
  7. APP = process.cwd();
  8. BIN = "" + APP + "/node_modules/.bin";
  9. CAKE = "" + BIN + "/cake" + EXT;
  10. COFFEE = "" + BIN + "/coffee" + EXT;
  11. DOCPAD = "" + BIN + "/docpad" + EXT;
  12. OUT = "" + APP + "/out";
  13. SRC = "" + APP + "/src";
  14. BROWSERIFY = "" + BIN + "/browserify" + EXT;
  15. pathUtil = require('path');
  16. _ref = require('child_process'), exec = _ref.exec, spawn = _ref.spawn;
  17. safe = function(next, fn) {
  18. return function(err) {
  19. if (err) {
  20. return next(err);
  21. }
  22. return fn();
  23. };
  24. };
  25. bench = function(opts, next) {
  26. if (next == null) {
  27. next = opts;
  28. opts = {};
  29. }
  30. return spawn(NODE, ["" + OUT + "/test/benchmark.js"], {
  31. stdio: 'inherit',
  32. cwd: APP
  33. }).on('close', next);
  34. };
  35. clean = function(opts, next) {
  36. var args;
  37. if (next == null) {
  38. next = opts;
  39. opts = {};
  40. }
  41. args = ['-Rf', OUT, pathUtil.join(APP, 'node_modules'), pathUtil.join(APP, '*out'), pathUtil.join(APP, '*log')];
  42. return spawn('rm', args, {
  43. stdio: 'inherit',
  44. cwd: APP
  45. }).on('close', next);
  46. };
  47. browserify = function(opts, next) {
  48. if (next == null) {
  49. next = opts;
  50. opts = {};
  51. }
  52. return spawn(BROWSERIFY, ["" + OUT + "/lib/js2coffee.js", '-s', 'js2coffee', '-o', "" + OUT + "/lib/browser.js"], {
  53. stdio: 'inherit',
  54. cwd: APP
  55. }).on('close', next);
  56. };
  57. compile = function(opts, next) {
  58. if (next == null) {
  59. next = opts;
  60. opts = {};
  61. }
  62. return spawn(DOCPAD, ['generate'], {
  63. stdio: 'inherit',
  64. cwd: APP
  65. }).on('close', next);
  66. };
  67. watch = function(opts, next) {
  68. if (next == null) {
  69. next = opts;
  70. opts = {};
  71. }
  72. return spawn(DOCPAD, ['watch'], {
  73. stdio: 'inherit',
  74. cwd: APP
  75. }).on('close', next);
  76. };
  77. install = function(opts, next) {
  78. if (next == null) {
  79. next = opts;
  80. opts = {};
  81. }
  82. return spawn(NPM, ['install'], {
  83. stdio: 'inherit',
  84. cwd: APP
  85. }).on('close', next);
  86. };
  87. reset = function(opts, next) {
  88. if (next == null) {
  89. next = opts;
  90. opts = {};
  91. }
  92. return clean(opts, safe(next, function() {
  93. return install(opts, safe(next, function() {
  94. return compile(opts, safe(next, function() {
  95. return browserify(opts, next);
  96. }));
  97. }));
  98. }));
  99. };
  100. setup = function(opts, next) {
  101. if (next == null) {
  102. next = opts;
  103. opts = {};
  104. }
  105. return install(opts, safe(next, function() {
  106. return compile(opts, safe(next, function() {
  107. return browserify(opts, next);
  108. }));
  109. }));
  110. };
  111. test = function(opts, next) {
  112. var args;
  113. if (next == null) {
  114. next = opts;
  115. opts = {};
  116. }
  117. args = [];
  118. if (opts.debug) {
  119. args.push("--debug-brk");
  120. }
  121. args.push("" + OUT + "/test/everything.js");
  122. return spawn(NODE, args, {
  123. stdio: 'inherit',
  124. cwd: APP
  125. }, next);
  126. };
  127. finish = function(err) {
  128. if (err) {
  129. throw err;
  130. }
  131. return console.log('OK');
  132. };
  133. task('bench', 'benchmark our project', function() {
  134. return bench(finish);
  135. });
  136. task('clean', 'clean up instance', function() {
  137. return clean(finish);
  138. });
  139. task('compile', 'compile our files', function() {
  140. return compile(browserify(finish));
  141. });
  142. task('dev', 'watch and recompile our files', function() {
  143. return watch(browserify(finish));
  144. });
  145. task('watch', 'watch and recompile our files', function() {
  146. return watch(browserify(finish));
  147. });
  148. task('install', 'install dependencies', function() {
  149. return install(finish);
  150. });
  151. task('reset', 'reset instance', function() {
  152. return reset(finish);
  153. });
  154. task('setup', 'setup for development', function() {
  155. return setup(finish);
  156. });
  157. task('test', 'run our tests', function() {
  158. return test(finish);
  159. });
  160. task('test-debug', 'run our tests in debug mode', function() {
  161. return test({
  162. debug: true
  163. }, finish);
  164. });
  165. task('test-prepare', 'prepare out tests', function() {
  166. return setup(finish);
  167. });