Gruntfile.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. module.exports = function(grunt) {
  2. var pkg = require("./package.json");
  3. global.jasmineVersion = pkg.version;
  4. var versionString = 'v' + pkg.version;
  5. grunt.initConfig({
  6. pkg: pkg,
  7. jshint: {all: ['lib/**/*.js', 'spec/**/*.js']}
  8. });
  9. var shell = require('shelljs');
  10. function runCommands(commands, done) {
  11. var command = commands.shift();
  12. if (command) {
  13. shell.exec(command, function(exitCode) {
  14. if (exitCode !== 0) {
  15. grunt.fail.fatal("Command `" + command + "` failed", exitCode);
  16. done();
  17. } else {
  18. runCommands(commands, done);
  19. }
  20. });
  21. } else {
  22. done();
  23. }
  24. }
  25. // depend on jshint:all, specs?
  26. grunt.registerTask('release',
  27. 'Create tag ' + versionString + ' and push jasmine-' + pkg.version + ' to NPM',
  28. function() {
  29. var done = this.async(),
  30. commands = ['git tag ' + versionString, 'git push origin master --tags', 'npm publish'];
  31. runCommands(commands, done);
  32. });
  33. grunt.loadNpmTasks('grunt-contrib-jshint');
  34. grunt.loadTasks('tasks');
  35. grunt.registerTask('default', ['jshint:all', 'specs']);
  36. };