Gruntfile.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. 'use strict';
  2. var fs = require('fs'),
  3. path = require('path');
  4. function findAmberPath(options) {
  5. var result;
  6. options.some(function (x) {
  7. var candidate = path.join(__dirname, x);
  8. return fs.existsSync(path.join(candidate, 'support/boot.js')) && (result = candidate);
  9. });
  10. return result;
  11. }
  12. module.exports = function (grunt) {
  13. var path = require('path');
  14. // These plugins provide necessary tasks.
  15. grunt.loadNpmTasks('grunt-execute');
  16. grunt.loadNpmTasks('grunt-contrib-clean');
  17. grunt.loadNpmTasks('grunt-contrib-less');
  18. grunt.loadNpmTasks('grunt-contrib-watch');
  19. grunt.loadNpmTasks('amber-dev');
  20. // Default task.
  21. grunt.registerTask('default', ['less', 'amberc:all']);
  22. grunt.registerTask('test', ['amberc:test_runner', 'execute:test_runner', 'clean:test_runner']);
  23. grunt.registerTask('devel', ['amdconfig:helios']);
  24. // Project configuration.
  25. grunt.initConfig({
  26. // Metadata.
  27. // pkg: grunt.file.readJSON(''),
  28. banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  29. '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  30. '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
  31. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  32. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
  33. // task configuration
  34. less: {
  35. development: {
  36. files: {
  37. 'resources/helios.css': 'resources/helios.less'
  38. }
  39. }
  40. },
  41. amberc: {
  42. options: {
  43. amber_dir: findAmberPath(['../..', 'bower_components/amber']),
  44. library_dirs: ['src', 'bower_components/amber-contrib-web/src']
  45. },
  46. all: {
  47. output_dir: 'src',
  48. src: [
  49. // list all sources in dependency order
  50. 'src/Helios-Core.st', 'src/Helios-Exceptions.st', 'src/Helios-Announcements.st',
  51. 'src/Helios-KeyBindings.st', 'src/Helios-Layout.st', 'src/Helios-Helpers.st',
  52. 'src/Helios-Commands-Core.st',
  53. 'src/Helios-Commands-Tools.st', 'src/Helios-Commands-Browser.st', 'src/Helios-Commands-SUnit.st',
  54. 'src/Helios-References.st', 'src/Helios-Inspector.st', 'src/Helios-Browser.st',
  55. 'src/Helios-Transcript.st', 'src/Helios-Workspace.st', 'src/Helios-Debugger.st',
  56. 'src/Helios-SUnit.st',
  57. // list all tests in dependency order
  58. 'src/Helios-Browser-Tests.st', 'src/Helios-Workspace-Tests.st', 'src/Helios-SUnit-Tests.st'
  59. ],
  60. libraries: ['Web', 'SUnit'],
  61. amd_namespace: 'helios',
  62. jsGlobals: ['navigator']
  63. },
  64. test_runner: {
  65. src: ['node_modules/amber-dev/lib/Test.st'],
  66. libraries: [
  67. /* add dependencies packages here */
  68. /* add other code-to-test packages here */
  69. 'SUnit',
  70. /* add other test packages here */
  71. ],
  72. main_class: 'NodeTestRunner',
  73. output_name: 'test_runner'
  74. }
  75. },
  76. amdconfig: {helios: {dest: 'config.js'}},
  77. execute: {
  78. test_runner: {
  79. src: ['test_runner.js']
  80. }
  81. },
  82. clean: {
  83. test_runner: ['test_runner.js']
  84. },
  85. watch: {
  86. less: {
  87. files: ['resources/*.less'],
  88. tasks: ['less'],
  89. options: {
  90. spawn: false
  91. }
  92. }
  93. }
  94. });
  95. };