Skip to content

Commit 72d6eee

Browse files
committed
Fix -SourceModule on Initialize-ModuleBuild
1 parent cbba327 commit 72d6eee

4 files changed

Lines changed: 29 additions & 13 deletions

File tree

plaster/ModuleBuild/plasterManifest.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
templateType="Project" xmlns="http://www.microsoft.com/schemas/PowerShell/Plaster/v1">
55
<metadata>
66
<name>ModuleBuild</name>
7-
<id>4b283342-b625-4db2-99c7-cf85de213289</id>
7+
<id>3fd34e00-75da-4e7d-96c4-64009f3790e2</id>
88
<version>0.0.1</version>
99
<title>New ModuleBuild Project</title>
1010
<description>Create a new PowerShell Module with a ModuleBuild wrapper</description>
@@ -24,6 +24,10 @@
2424
name="ModuleAuthor"
2525
type="text"
2626
prompt="Enter a module author" />
27+
<parameter
28+
name="ModuleCompanyName"
29+
type="text"
30+
prompt="Enter a module company name" />
2731
<parameter
2832
name="ModuleWebsite"
2933
type="text"
@@ -147,9 +151,9 @@
147151
<content>
148152
<newModuleManifest
149153
description="${PLASTER_PARAM_ModuleDescription}"
150-
copyright="(c) ${PLASTER_Year} ${PLASTER_PARAM_ModuleAuthor}. All rights reserved."
154+
copyright="(c) ${PLASTER_Year} ${PLASTER_PARAM_ModuleCompanyName}. All rights reserved."
151155
tags="${PLASTER_PARAM_ModuleTags}"
152-
companyName="${PLASTER_PARAM_ModuleAuthor}"
156+
companyName="${PLASTER_PARAM_ModuleCompanyName}"
153157
author="${PLASTER_PARAM_ModuleAuthor}"
154158
licenseUri="${PLASTER_PARAM_ModuleWebsite}/raw/master/LICENSE.md"
155159
projectUri="${PLASTER_PARAM_ModuleWebsite}"

plaster/PlasterContent.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ $Content = @(
44
Destination = '${PLASTER_PARAM_ModuleName}.psd1'
55
moduleVersion = '${PLASTER_PARAM_ModuleVersion}'
66
rootModule = '${PLASTER_PARAM_ModuleName}.psm1'
7-
copyright = '(c) ${PLASTER_Year} ${PLASTER_PARAM_ModuleAuthor}. All rights reserved.'
7+
copyright = '(c) ${PLASTER_Year} ${PLASTER_PARAM_ModuleCompanyName}. All rights reserved.'
88
projectURI = '${PLASTER_PARAM_ModuleWebsite}'
99
licenseURI = '${PLASTER_PARAM_ModuleWebsite}/raw/master/LICENSE.md'
1010
iconURI = '${PLASTER_PARAM_ModuleWebsite}/raw/master/src/other/powershell-project.png'
1111
author = '${PLASTER_PARAM_ModuleAuthor}'
12-
companyname = '${PLASTER_PARAM_ModuleAuthor}'
12+
companyname = '${PLASTER_PARAM_ModuleCompanyName}'
1313
description = '${PLASTER_PARAM_ModuleDescription}'
1414
tags = '${PLASTER_PARAM_ModuleTags}'
1515
functionsToExport = '*'

plaster/PlasterParams.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ $Parameters = @(
1515
ParameterType = "text"
1616
ParameterPrompt = "Enter a module author"
1717
},
18+
@{
19+
ParameterName = "ModuleCompanyName"
20+
ParameterType = "text"
21+
ParameterPrompt = "Enter a module company name"
22+
},
1823
@{
1924
ParameterName = "ModuleWebsite"
2025
ParameterType = "text"

src/public/Initialize-ModuleBuild.ps1

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,35 @@ Enjoy!
6868
'@
6969

7070
if (-not [string]::IsNullOrEmpty($SourceModule)) {
71-
if (-not (test-path $SourceModule) -or ($SourceModule -notmatch '*.psd1')) {
72-
throw 'SourceModule was not found or is not a psd1 module manifest file!'
71+
if (-not [string]::IsNullOrEmpty($SourceModule))
72+
{
73+
if (-not (test-path $SourceModule) -or ((Get-Item $SourceModule).Extension -notmatch '.psd1')) {
74+
throw "$($SourceModule) was not found or is not a psd1 module manifest file!"
75+
} ElseIf ((test-path $SourceModule) -and (Get-Item $SourceModule).Extension -match '.psd1') {
76+
Write-Verbose "$($SourceModule) Matched to .psd1 file"
77+
}
7378
}
74-
79+
7580
$ExistingModuleManifest = Test-ModuleManifest $SourceModule
7681

77-
$ModuleProps = @{
82+
$PlasterParams = @{
7883
TemplatePath = Join-Path $MyModulePath 'plaster\ModuleBuild\';
7984
ModuleName = $ExistingModuleManifest.Name;
8085
ModuleDescription = $ExistingModuleManifest.Description;
8186
ModuleAuthor = $ExistingModuleManifest.Author;
87+
ModuleCompanyName = $ExistingModuleManifest.CompanyName;
8288
ModuleWebsite = $ExistingModuleManifest.ProjectURI.ToString();
8389
ModuleVersion = $ExistingModuleManifest.Version.ToString();
8490
ModuleTags = $ExistingModuleManifest.Tags -join ',';
8591
}
86-
}
87-
$PlasterParams = @{
88-
TemplatePath = Join-Path $MyModulePath 'plaster\ModuleBuild\'
92+
} else {
93+
$PlasterParams = @{
94+
TemplatePath = Join-Path $MyModulePath 'plaster\ModuleBuild\'
95+
}
8996
}
9097
if (-not [string]::IsNullOrEmpty($Path)) {
9198
$PlasterParams.DestinationPath = $Path
92-
}
99+
}
93100

94101
if (get-module Plaster) {
95102
Write-Output 'Removing already loaded version of Plaster as we need to use our custom version instead..'

0 commit comments

Comments
 (0)