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', function() { |
| 659 | var isSvn = fs.existsSync('.svn'), |
| 660 | isGit = fs.existsSync('.git'); |
| 661 | var done = this.async(); |
| 662 | if ( isSvn ) { |
| 663 | grunt.util.spawn( |
| 664 | { |
| 665 | cmd: 'svn', |
| 666 | args: ['diff', '--summarize'] |
| 667 | }, |
| 668 | function(error, result, code) { |
| 669 | var taskList = ['imagemin:core']; |
| 670 | // Bail if the svn diff command returned a non-zero exit code. |
| 671 | if ( code !== 0 ) { |
| 672 | done(); |
| 673 | } |
| 674 | // Figure out what tasks to run based on what files have been modified. |
| 675 | if ( /\.js/.test( result.stdout ) ) { |
| 676 | taskList = taskList.concat( ['browserify', 'jshint:corejs', 'uglify:bookmarklet', 'qunit:compiled'] ); |
| 677 | } |
| 678 | if ( /\.s?css/.test( result.stdout ) ) { |
| 679 | taskList.push( 'postcss:core' ); |
| 680 | } |
| 681 | if ( /\.s?css/.test( result.stdout ) ) { |
| 682 | taskList.push( 'phpunit' ); |
| 683 | } |
| 684 | grunt.task.run( taskList ); |
| 685 | done(); |
| 686 | } |
| 687 | ); |
| 688 | } else if ( isGit ) { |
| 689 | } |
| 690 | }); |