@@ -14,40 +14,44 @@ Param(
14
14
function IncrementVersion ([string ]$FilePath )
15
15
{
16
16
Write-Output " Updating File: $FilePath "
17
- $content = Get-Content $FilePath
18
- $matches = ([regex ]::matches($content , " ModuleVersion = '([\d\.]+)'" ))
17
+ (Get-Content $FilePath ) |
18
+ ForEach-Object {
19
+ $matches = ([regex ]::matches($_ , " ModuleVersion = '([\d\.]+)'" ))
19
20
20
- $packageVersion = $matches.Groups [1 ].Value
21
- $version = $packageVersion.Split (" ." )
22
-
23
- $cMajor = $Major
24
- $cMinor = $Minor
25
- $cPatch = $Patch
26
-
27
- if ($cMajor )
28
- {
29
- $version [0 ] = 1 + $version [0 ]
30
- $version [1 ] = " 0"
31
- $version [2 ] = " 0"
32
- }
33
-
34
- if ($cMinor )
35
- {
36
- $version [1 ] = 1 + $version [1 ]
37
- $version [2 ] = " 0"
38
- }
39
-
40
- if ($cPatch )
41
- {
42
- $version [2 ] = 1 + $version [2 ]
43
- }
44
-
45
- $version = [String ]::Join(" ." , $version )
46
-
47
- Write-Output " Updating version of $FilePath from $packageVersion to $version "
48
- $content = $content.Replace (" ModuleVersion = '$packageVersion '" , " ModuleVersion = '$version '" )
49
-
50
- Set-Content - Path $FilePath - Value $content - Encoding UTF8
21
+ if ($matches.Count -eq 1 )
22
+ {
23
+ $packageVersion = $matches.Groups [1 ].Value
24
+ $version = $packageVersion.Split (" ." )
25
+
26
+ $cMajor = $Major
27
+ $cMinor = $Minor
28
+ $cPatch = $Patch
29
+
30
+ if ($cMajor )
31
+ {
32
+ $version [0 ] = 1 + $version [0 ]
33
+ $version [1 ] = " 0"
34
+ $version [2 ] = " 0"
35
+ }
36
+
37
+ if ($cMinor )
38
+ {
39
+ $version [1 ] = 1 + $version [1 ]
40
+ $version [2 ] = " 0"
41
+ }
42
+
43
+ if ($cPatch )
44
+ {
45
+ $version [2 ] = 1 + $version [2 ]
46
+ }
47
+
48
+ $version = [String ]::Join(" ." , $version )
49
+ $_.Replace (" ModuleVersion = '$packageVersion '" , " ModuleVersion = '$version '" )
50
+ } else {
51
+ $_
52
+ }
53
+
54
+ } | Set-Content - Path $FilePath - Encoding UTF8
51
55
}
52
56
53
57
if (! $Folder )
0 commit comments