2
0

grunt-amdconfig.js 861 B

12345678910111213141516171819202122232425262728293031323334
  1. module.exports = function (grunt) {
  2. /**
  3. Example Gruntfile.js entry:
  4. amberconfig: {
  5. options: {
  6. root_dir: process.cwd(), //optional
  7. },
  8. app: {
  9. dest: 'config.js' //required
  10. }
  11. }
  12. */
  13. grunt.registerMultiTask('amdconfig', 'Build amd config of AMD project', function () {
  14. // mark task as async task
  15. var done = this.async();
  16. var options = this.options({
  17. root_dir: '.'
  18. });
  19. if (this.files.length === 0) {
  20. grunt.fail.warn('No destination file specified.');
  21. }
  22. if (this.files.length > 1) {
  23. grunt.fail.warn('Only one destination file supported.');
  24. }
  25. require('../lib/config.js').writeConfig(options.root_dir, this.files[0].dest, function (err) {
  26. done(!err);
  27. })
  28. });
  29. };