-
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
Pass callback to grunt.task.run #1184
Comments
+1 |
FWIW, something similar is planned for v0.5. See #542 |
+1 |
2 similar comments
+1 |
+1 |
👍 //cc @cowboy |
+1 |
2 similar comments
+1 |
+1 |
+1 |
👍 +1 |
+1 |
Yes, please. Gimme two. |
+1 |
2 similar comments
+1 |
+1 |
+! |
Please just hit "Subscribe" rather than reply with "+1" which spams everyone following the thread, thanks. |
+1 |
2 similar comments
+1 |
+1 |
there should also be an argument with the task completion status code in this "finalize callback" and a possitibility to to avoid interruption of the task flow; grunt.task.run('some-task', function (status) {
console.log('some-task completed with status: ' + status);
return true; // force continue
}); |
+1 |
1 similar comment
+1 |
Please just click "Subscribe" on the right instead of replying to +1 (which pings all subscribers), thanks. |
I just now finished making grunt.task
.run("some-task")
.then(function () {
// do stuff after "some-task" completes, but before "other-task" begins
})
.run("other-task") Check out the repo to learn more. |
+1 |
1 similar comment
+1 |
👍 |
+1 |
5 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
1 similar comment
👍 |
Please just click the subscribe button and use the new emoji feature instead of commenting (@RickBRoss, @MusikAnimal). |
I guess those days it would be better to have |
Besides, mentioned workaround grunt.task.run('internal-task', 'some-task');
// or
grunt.task.run('some-task', 'internal-task'); Will not work for tests well, because you don't have in |
Well, after looking into Line 166 in a09f84c
I now see that this isn't that simple as simply passing a callback. After some looking closer and testing, it turned out that grunt.task.run(['youTask`']).start() is synchronous. So, it is possible to do something like this grunt.task.run(['image_size:test']).start()
console.log(grunt.config(buildPath.test.property))
expect(readJSON(buildPath.test.dest)).toMatchSnapshot() However, while it mostly works, it puts Jest in watch mode into an endless loop. I guess it has something to do with the way Grunt exits the process. Besides, using So far I assume that it can be mitigated by introducing callback or promises to The alternative would be to use process spawning (as here), but while working mostly flawlessly, it has a major drawback — you can't mutate with tasks Grunt's context and access it afterwards. Which is crucial for some tests. |
+1 |
grunt.task.run
runs a task after another has finished. However I need to run a task from within a task and process things after the other task has finished. An API like this would be beautiful:I couldn't find a way to do that with the current API.
EDIT:
What I currently do to solve this problem. I use another internal task which runs before/after my
some-task
. This internal task is only needed to set some dynamic config and shouldn't be called manually. Usage looks like this:The text was updated successfully, but these errors were encountered: