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

Added a Remove-Template command #31

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Added a Remove-Template command #31

wants to merge 2 commits into from

Conversation

MikaelPorttila
Copy link

This code should be fine.
I noticed that $Global:pecanwafflesettings.Templates gets reset in every new Powershell instance - bug or feature? :)

@sayedihashimi
Copy link
Member

Thanks for the PR, I'm going to take a look now.

I noticed that $Global:pecanwafflesettings.Templates gets reset in every new Powershell instance - bug or feature? :)

You can override those settings with env vars, see https://github.com/ligershark/pecan-waffle/wiki/How-to-use-the-build-script#special-environment-variables.

function Remove-PWTemplate{
[cmdletbinding()]
param(
[Parameter(Position=1,Mandatory=$true)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add ValueFromPipeline=$true here? This will enable piping for example

'aspnet-empty`,`aspnet-web` | Remove-PWTemplate

@sayedihashimi
Copy link
Member

@MikaelPorttila thanks a lot for the contribution! I made a few comments on the PR.

Would you also consider adding a unit test to main.tests.ps1? I looked to see if there was a good test that you could copy/paste to get started but I didn't find a good one. I think to test this the easiest way is to register two or more templates and then call the remove function. To do that I think the following would work.

    $templateInfo = New-Object -TypeName psobject -Property @{
        Name = 'test01'
        Type = 'ProjectTemplate'
    }

    Set-TemplateInfo -templateInfo $templateInfo -templateRoot $pwd

    $templateInfo = New-Object -TypeName psobject -Property @{
        Name = 'test02'
        Type = 'ProjectTemplate'
    }

    Set-TemplateInfo -templateInfo $templateInfo -templateRoot $pwd

    Remove-PWTemplate 'test01'
    # todo: validate

FYI since you sent the PR I wrote up some notes on how to use the build script at https://github.com/ligershark/pecan-waffle/wiki/How-to-use-the-build-script. It's pretty easy to get started with that.

Thanks again for the PR.

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