-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setup and teardown, or revert back to this.files. #606
Comments
I'm very close to removing the current The |
And FWIW, @tkellen and I have already been prototyping a setup/eachfile/teardown system for 0.5. It's gonna be awesome. |
I think reverting back to Though this will break almost every single task, since 0.3 didn't have this.files and all tasks that has upgraded to 0.4pre uses this.file... Previously brought up in #546 |
I can do what I did before, which is to set |
im trying to think of times when tasks would care if it was run individually. mainly only when working with a single output file from what i've come up with. maybe we should build a list of more times when current logic will be a problem? i think for v0.4 we could get away with a way for task define that it cant run multiple times per target. and in those cases grunt can just compile all the file pairs and pass it as an array for that task to handle. seems easiest route? |
I have reverted the whole gh-524 file object implicit iteration abstraction, you can get the latest version here: https://github.com/gruntjs/grunt/tree/file-mapping I'll repeat my commit comments here:
Tasks can iterate over this.files.forEach(function(f) {
doSomethingSyncWith(f.src, f.dest);
}, this); Tasks can iterate over grunt.util.async.forEach(this.files, function(f, next) {
doSomethingAsyncWith(f.src, f.dest, next);
}.bind(this), this.async()); Synchronous read-only tasks like jshint can do this: this.filesSrc.forEach(function(filepath) {
doSomethingSyncWith(filepath);
}, this); Please review my commit ASAP so I can start updating plugins to work with the new (old) format, /cc @sindresorhus @shama @tkellen @ctalkington @tbranyen |
Lgtm |
Ok, these changes (and others, including the new declarative file mapping stuff) are now in master. Time to update some contrib plugins! |
* this.files.forEach iterates over all src-dest file pairs. * f.src.filter() warns on and removes possible invalid source files (in case the user set nonull), but doesn't fail the task. * Uncaught exceptions will fail the task.
* Since grunt.file.expandFileURLs has been removed, URLs may now be specified via a "urls" option. * URLs and src files will be concatenated and processed in-order.
* this.files.forEach iterates over all src-dest file pairs. * f.src.filter() warns on and removes possible invalid source files (in case the user set nonull), but doesn't fail the task. * Uncaught exceptions will fail the task.
…grunt 0.4.0rc5.
Updating to support new this.filesSrc property per gruntjs/grunt#606.
…grunt 0.4.0rc5.
I just realized that if we're going to continue with
this.file
we will need setup and teardown in tasks for 0.4.Chris showed me his "compress" code. The way it needs to work, fundamentally, is:
Opening up an already-finalized archive isn't an option.
So, in order for this to work, we really need to get setup and teardown happening.
With the current "only an eachfile function" implementation, the task function only knows about one src-dest at a time, and as such can't actually utilized the declarative expand mapping system. It'd have to parse it manually. Which isn't good, because then it limits the user to one declarative expand mapping per zipfile, which is really limiting. And also totally gross.
I'm really afraid this is going to push 0.4 off for another month, which is totally not an option. Either way, we need to figure out a solution for this as soon as possible!
Maybe a new
.registerTask
syntax that looks something more like:Although I'm afraid that this task format raises more questions than it answers. Like, how do we parse options, how do we persist state, fail tasks, etc.
I'm not sure we can actually do something like this in 0.4, and feel like we might need to revert back to calling the task function once with an already-expanded
this.files
array, like we did in an earlier 0.4.The text was updated successfully, but these errors were encountered: