Skip to content
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 @before hook #242

Merged
merged 1 commit into from
Feb 5, 2022
Merged

Conversation

bakerkretzmar
Copy link
Contributor

@bakerkretzmar bakerkretzmar commented Feb 4, 2022

This PR adds a new @before hook, identical to @after except that it runs before each task. Like @after and @error it receives the name of the task.

@before
    if ($task === 'finalize_release') {
        echo "Almost done!";
    }
@endbefore

My use case for this is outputting a friendly description of each task in a long story as it runs, without having the commands to echo out the messages cluttering up the beginning of every single task. I imagine there are lots of other uses for it too, like waiting for something to become available before starting a task, or making an initial measurement and then doing before/after comparisons when a task is finished.

If this PR is accepted I'll add this to the docs too.

@taylorotwell taylorotwell merged commit 65cea91 into laravel:2.x Feb 5, 2022
@bakerkretzmar bakerkretzmar deleted the before-callbacks branch February 6, 2022 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants