657 | | grunt.registerTask( 'precommit', 'Runs front-end dev/test tasks in preparation for a commit.', [ |
658 | | 'postcss:core', |
659 | | 'imagemin:core', |
660 | | 'browserify', |
661 | | 'jshint:corejs', |
662 | | 'uglify:bookmarklet', |
663 | | 'qunit:compiled' |
664 | | ] ); |
| 658 | grunt.registerTask( 'precommit', 'Runs test and build tasks in preparation for a commit', function() { |
| 659 | var done = this.async(); |
| 660 | gitorsvn( __dirname, function(gitorsvn) { |
| 661 | if ( gitorsvn === 'svn' ) { |
| 662 | grunt.util.spawn( |
| 663 | { |
| 664 | cmd: 'svn', |
| 665 | args: ['diff', '--summarize'] |
| 666 | }, |
| 667 | function(error, result, code) { |
| 668 | var taskList = ['imagemin:core']; |
| 669 | // Bail if the svn diff command returned a non-zero exit code. |
| 670 | if ( code !== 0 ) { |
| 671 | grunt.fail.warn( 'The `svn diff` command returned a non-zero exit code.', code ); |
| 672 | } |
| 673 | // Figure out what tasks to run based on what files have been modified. |
| 674 | if ( /\.js/.test( result.stdout ) ) { |
| 675 | taskList = taskList.concat( ['browserify', 'jshint:corejs', 'uglify:bookmarklet', 'qunit:compiled'] ); |
| 676 | } |
| 677 | if ( /\.s?css/.test( result.stdout ) ) { |
| 678 | taskList.push( 'postcss:core' ); |
| 679 | } |
| 680 | if ( /\.s?css/.test( result.stdout ) ) { |
| 681 | taskList.push( 'phpunit' ); |
| 682 | } |
| 683 | grunt.task.run( taskList ); |
| 684 | done(); |
| 685 | } |
| 686 | ); |
| 687 | } else if ( gitorsvn === 'git' ) {} |
| 688 | }); |
| 689 | }); |