commit/galaxy-central: carlfeberhard: Client build system, copy task: make much more efficient by calling 'copy' with just those files that have changed
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0111073204bc/ Changeset: 0111073204bc User: carlfeberhard Date: 2014-09-17 14:10:13+00:00 Summary: Client build system, copy task: make much more efficient by calling 'copy' with just those files that have changed Affected #: 1 file diff -r 02738142b8cf5e0372ac5c2b46eeff5f0ab8e87a -r 0111073204bca68f004c2830eb1a249f17d5741e client/GruntFile.js --- a/client/GruntFile.js +++ b/client/GruntFile.js @@ -8,10 +8,14 @@ // use 'grunt copy' to copy the entire <galaxy>/client/galaxy/scripts dir into <galaxy>/static/scripts copy: { main: { - expand: true, - cwd: 'galaxy/scripts/', - src: '**', - dest: '../static/scripts/' + files: [ + { + expand : true, + cwd : 'galaxy/scripts/', + src : '**', + dest : '../static/scripts' + } + ] } }, @@ -19,12 +23,36 @@ watch: { // watch for changes in the src dir files: [ 'galaxy/scripts/**' ], - tasks: [ 'default' ] + tasks: [ 'copy' ], + options: { + spawn: false + } } }); grunt.loadNpmTasks( 'grunt-contrib-watch' ); grunt.loadNpmTasks( 'grunt-contrib-copy'); + // adapted from grunt-contrib-watch jslint example + //TODO: a bit hacky and there's prob. a better way + //NOTE: copy will fail silently if a file isn't found + var changedFiles = Object.create(null); + var onChange = grunt.util._.debounce(function() { + grunt.config( 'copy.main.files', [{ + expand: true, + cwd: 'galaxy/scripts', + src: Object.keys( changedFiles ), + dest: '../static/scripts/' + }]); + changedFiles = Object.create(null); + }, 200); + grunt.event.on('watch', function(action, filepath) { + // store each filepath in a Files obj, the debounced fn above will use it as an aggregate list for copying + // we need to take galaxy/scripts out of the filepath or it will be copied to the wrong loc + filepath = filepath.replace( /galaxy\/scripts\//, '' ); + changedFiles[filepath] = action; + onChange(); + }); + grunt.registerTask( 'default', [ 'copy' ] ); }; Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org