2
0

Gruntfile.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. 'use strict';
  2. module.exports = function (grunt) {
  3. var path = require('path');
  4. // These plugins provide necessary tasks.
  5. grunt.loadNpmTasks('grunt-contrib-clean');
  6. grunt.loadNpmTasks('grunt-contrib-requirejs');
  7. grunt.loadNpmTasks('grunt-execute');
  8. grunt.loadNpmTasks('amber-dev');
  9. // Default task.
  10. grunt.registerTask('default', ['amberc:all']);
  11. grunt.registerTask('test', ['amberc:test_runner', 'execute:test_runner', 'clean:test_runner']);
  12. grunt.registerTask('devel', ['amdconfig:app', 'requirejs:devel']);
  13. grunt.registerTask('deploy', ['amdconfig:app', 'requirejs:deploy']);
  14. // Project configuration.
  15. grunt.initConfig({
  16. // Metadata.
  17. // pkg: grunt.file.readJSON(''),
  18. banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  19. '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  20. '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
  21. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  22. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
  23. // task configuration
  24. amberc: {
  25. options: {
  26. amber_dir: path.join(__dirname, "bower_components", "amber"),
  27. library_dirs: ['src'],
  28. closure_jar: ''
  29. },
  30. all: {
  31. src: [
  32. 'src/AmberSnapsvg.st', // list all sources in dependency order
  33. 'src/AmberSnapsvg-Tests.st' // list all tests in dependency order
  34. ],
  35. amd_namespace: 'amber-snapsvg',
  36. libraries: ['SUnit', 'Web']
  37. },
  38. test_runner: {
  39. src: ['node_modules/amber-dev/lib/Test.st'],
  40. libraries: [
  41. /* add dependencies packages here */
  42. 'AmberSnapsvg', /* add other code-to-test packages here */
  43. 'SUnit',
  44. 'AmberSnapsvg-Tests' /* add other test packages here */
  45. ],
  46. main_class: 'NodeTestRunner',
  47. output_name: 'test_runner'
  48. }
  49. },
  50. amdconfig: {app: {dest: 'config.js'}},
  51. requirejs: {
  52. deploy: {options: {
  53. mainConfigFile: "config.js",
  54. onBuildWrite: function (moduleName, path, contents) {
  55. return moduleName === "config" ? contents + "\nrequire.config({map:{'*':{app:'deploy'}}});" : contents;
  56. },
  57. pragmas: {
  58. excludeIdeData: true,
  59. excludeDebugContexts: true
  60. },
  61. include: ['config', 'node_modules/requirejs/require', 'deploy'],
  62. out: "the.js"
  63. }},
  64. devel: {options: {
  65. mainConfigFile: "config.js",
  66. onBuildWrite: function (moduleName, path, contents) {
  67. return moduleName === "config" ? contents + "\nrequire.config({map:{'*':{app:'devel'}}});" : contents;
  68. },
  69. include: ['config', 'node_modules/requirejs/require'],
  70. out: "the.js"
  71. }}
  72. },
  73. execute: {
  74. test_runner: {
  75. src: ['test_runner.js']
  76. }
  77. },
  78. clean: {
  79. test_runner: ['test_runner.js']
  80. }
  81. });
  82. };