BuildCommon.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. var fs = require('fs-extra');
  2. var os = require('os');
  3. var path = require("path");
  4. var host = require("./Host");
  5. var atomicRoot = host.atomicRoot;
  6. var glob = require('glob');
  7. namespace('build', function() {
  8. task('genscripts', {
  9. async: true
  10. }, function(platform) {
  11. process.chdir(atomicRoot);
  12. var modules = host.getScriptModules(platform);
  13. var bindCmd = host.atomicTool + " bind \"" + atomicRoot + "\" ";
  14. var node;
  15. var tsc = "./Build/node_modules/typescript/lib/tsc";
  16. var tslint = "./Build/node_modules/tslint/lib/tslint-cli";
  17. switch(os.platform()) {
  18. case "win32":
  19. node = "Build/Windows/node/node.exe";
  20. break;
  21. case "darwin":
  22. node = "Build/Mac/node/node";
  23. break;
  24. case "linux":
  25. node = "Build/Linux/node/node";
  26. break;
  27. }
  28. var cmds = [];
  29. for (var pkgName in modules) {
  30. cmds.push(bindCmd + "Script/Packages/" + pkgName + "/ " + platform);
  31. }
  32. if (node) {
  33. // compile
  34. cmds.push(node + " " + tsc + " -p ./Script");
  35. // lint
  36. // Since TSLint does not yet support recursively searching for files, then we need to
  37. // create a command per file. The main issue with this is that it will abort on the first error instead
  38. // of listing out all lint errors
  39. glob("./Script/AtomicEditor/**/*.ts", function(err, results) {
  40. results.forEach(function(file) {
  41. cmds.push(node + " " + tslint + " -c ./Script/tslint.json " + file);
  42. });
  43. jake.exec(cmds, function() {
  44. complete();
  45. }, {
  46. printStdout: true
  47. });
  48. });
  49. } else {
  50. throw new Error("Node not configured for this platform: " + os.platform());
  51. }
  52. });
  53. }); // end of build namespace