Skip to content

Commit 56458a2

Browse files
Merge pull request #256 from PowershellFrameworkCollective/New-Commands
New commands
2 parents 2121fe2 + 0ee196e commit 56458a2

21 files changed

Lines changed: 288 additions & 14 deletions

File tree

PSFramework/PSFramework.psd1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
'Import-PSFLocalizedString',
9494
'Install-PSFLoggingProvider',
9595
'Invoke-PSFCommand',
96+
'Join-PSFPath',
9697
'New-PSFLicense',
9798
'New-PSFMessageLevelModifier',
9899
'New-PSFSupportPackage',
@@ -107,6 +108,7 @@
107108
'Register-PSFTeppArgumentCompleter',
108109
'Register-PSFTeppScriptblock',
109110
'Register-PSFTypeSerializationData',
111+
'Remove-PSFAlias',
110112
'Remove-PSFLicense',
111113
'Remove-PSFMessageLevelModifier',
112114
'Reset-PSFConfig',

PSFramework/PSFramework.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function Import-ModuleFile
5858
if ($doDotSource) { . (Resolve-Path $Path) }
5959
else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText((Resolve-Path $Path).ProviderPath))), $null, $null) }
6060
}
61-
catch { throw (New-Object System.Exception("Failed to import $(Resolve-Path $Path) _ $_", $_.Exception)) }
61+
catch { throw (New-Object System.Exception("Failed to import $(Resolve-Path $Path) : $_", $_.Exception)) }
6262
}
6363

6464
#region Load individual files

PSFramework/bin/PSFramework.dll

1 KB
Binary file not shown.

PSFramework/bin/PSFramework.pdb

0 Bytes
Binary file not shown.

PSFramework/bin/PSFramework.xml

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSFramework/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# CHANGELOG
2+
## 0.10.30.165 : 2018-12-01
3+
- New: Command Join-PSFPath performs multi-segment path joins and path normalization
4+
- New: Command Remove-PSFAlias deletes global aliases
5+
- New: Configuration setting to define current language
6+
- Upd: PsfValidatePattern now supports localized strings using the `ErrorString` property.
7+
- Fix: Race condition / concurrent access on license content during import with ramping up CPU availability
8+
29
## 0.10.29.160 : 2018-11-04
310
- New: Command ConvertTo-PSFHashtable converts objects into hashtables
411
- New: Command Get-PSFPipeline grants access to the current pipeline and all its works.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@{
2+
Assembly_UtilityHost_AliasNotFound = 'Failed to find alias: {0}'
3+
Assembly_UtilityHost_AliasProtected = 'The alias "{0}" is protected and cannot be removed!'
4+
Assembly_UtilityHost_AliasReadOnly = 'The alias "{0}" is read only! To remove it, also specify the "-Force" parameter.'
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Configuration_ValidateLanguage = '{0} is not recognized as a legal language code, such as "en-US" or "de-DE"'
3+
}

PSFramework/functions/localization/Import-PSFLocalizedString.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
.EXAMPLE
2525
PS C:\> Import-PSFLocalizedString -Path '$moduleRoot\strings.psd1' -Module 'MyModule'
2626
27-
Improts the strigns stored in strings.psd1 for the module MyModule as 'en-US' language strings.
27+
Imports the strings stored in strings.psd1 for the module MyModule as 'en-US' language strings.
2828
#>
2929
[CmdletBinding()]
3030
param (
@@ -54,8 +54,4 @@
5454
[PSFramework.Localization.LocalizationHost]::Write($Module, $key, $Language, $data[$key])
5555
}
5656
}
57-
end
58-
{
59-
60-
}
6157
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
function Join-PSFPath
2+
{
3+
<#
4+
.SYNOPSIS
5+
Performs multisegment path joins.
6+
7+
.DESCRIPTION
8+
Performs multisegment path joins.
9+
10+
.PARAMETER Path
11+
The basepath to join on.
12+
13+
.PARAMETER Child
14+
Any number of child paths to add.
15+
16+
.PARAMETER Normalize
17+
Normalizes path separators for the path segments offered.
18+
This ensures the correct path separators for the current OS are chosen.
19+
20+
.EXAMPLE
21+
PS C:\> Join-PSFPath -Path 'C:\temp' 'Foo' 'Bar'
22+
23+
Returns 'C:\temp\Foo\Bar'
24+
25+
.EXAMPLE
26+
PS C:\> Join-PSFPath -Path 'C:\temp' 'Foo' 'Bar' -Normalize
27+
28+
Returns 'C:\temp\Foo\Bar' on a Windows OS.
29+
Returns 'C:/temp/Foo/Bar' on most non-Windows OSes.
30+
#>
31+
[CmdletBinding()]
32+
param (
33+
[Parameter(Mandatory = $true, Position = 0)]
34+
[string]
35+
$Path,
36+
37+
[Parameter(ValueFromRemainingArguments = $true)]
38+
[string[]]
39+
$Child,
40+
41+
[switch]
42+
$Normalize
43+
)
44+
45+
$resultingPath = $Path
46+
47+
foreach ($childItem in $Child)
48+
{
49+
$resultingPath = Join-Path -Path $resultingPath -ChildPath $childItem
50+
}
51+
52+
if ($Normalize)
53+
{
54+
$defaultSeparator = [System.IO.Path]::DirectorySeparatorChar
55+
$altSeparator = "/"
56+
if ($defaultSeparator -eq "/") { $altSeparator = "\" }
57+
$resultingPath = $resultingPath.Replace($altSeparator, $defaultSeparator)
58+
}
59+
60+
$resultingPath
61+
}

0 commit comments

Comments
 (0)