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

Simpler hooks (2017-01-04-powershell-module-pipeline.md) #1

Closed
nightroman opened this Issue Jan 27, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@nightroman

nightroman commented Jan 27, 2017

2017-01-04-powershell-module-pipeline is a great post. As the author of Invoke-Build, I am glad it is recommended as the task runner. I have a remark on task hooks.

Here is what proposed in the blog post:

    ###############################################################################
    # Main build script with hooks
    ###############################################################################

    # Synopsis: Clean Artifacts Directory
    task Clean BeforeClean, {
        # ...
    }, AfterClean

    ###############################################################################
    # Extra x.settings.ps1 with dummy hooks
    ###############################################################################

    # Synopsis: Executes before the Clean task.
    task BeforeClean {}

    # Synopsis: Executes after the Clean task.
    task AfterClean {}

There is nothing wrong with this and in PSake this is probably the only way.

In Invoke-Build, though, we can use simpler hooks, thanks to Before and After.
See the example below. Note that example hooks are commented out, we do not have
to define dummy hooks. We just define them when needed and use Before or After.

    ###############################################################################
    # Main build script. Note that we do not have to pre-define/inject hooks
    ###############################################################################

    # Synopsis: Clean Artifacts Directory
    task Clean {
        # ...
    }

    ###############################################################################
    # Extra x.settings.ps1, note that we do not have to define dummy hooks
    ###############################################################################

    # Synopsis: Executes before the Clean task.
    #task BeforeClean -Before Clean {}

    # Synopsis: Executes after the Clean task.
    #task AfterClean -After Clean {}

Xainey added a commit that referenced this issue Jan 28, 2017

@Xainey

This comment has been minimized.

Show comment
Hide comment
@Xainey

Xainey Jan 28, 2017

Owner

Thanks for the feedback. I feel like your suggestion is much cleaner. I've updated the article for include -Before and -After. I will try to make further revisions to include this in my example projects.

Do you have any suggestions for the Test task I created? Originally, I played with the checkpoints and ended up saving and reading the test result files.

# Synopsis: Run/Publish Tests and Fail Build on Error
task Test RunTests, ConfirmTestsPassed

# Synopsis: Executes before the Test task.
#task BeforeTest -Before Test {}

# Synopsis: Executes after the Test task.
#task AfterTest -After Test {}
Owner

Xainey commented Jan 28, 2017

Thanks for the feedback. I feel like your suggestion is much cleaner. I've updated the article for include -Before and -After. I will try to make further revisions to include this in my example projects.

Do you have any suggestions for the Test task I created? Originally, I played with the checkpoints and ended up saving and reading the test result files.

# Synopsis: Run/Publish Tests and Fail Build on Error
task Test RunTests, ConfirmTestsPassed

# Synopsis: Executes before the Test task.
#task BeforeTest -Before Test {}

# Synopsis: Executes after the Test task.
#task AfterTest -After Test {}
@nightroman

This comment has been minimized.

Show comment
Hide comment
@nightroman

nightroman Jan 28, 2017

Very good, I am closing this then.
I do not have any suggestions on Test.

nightroman commented Jan 28, 2017

Very good, I am closing this then.
I do not have any suggestions on Test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment