mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Avoid use of mkdir alias in *.ps1 and *.psm1 (#8582)
This commit is contained in:
@@ -182,7 +182,7 @@ function Enable-PSWSManCombinedTrace
|
||||
|
||||
if (!(Test-Path $pshome\Traces))
|
||||
{
|
||||
mkdir -Force $pshome\Traces | out-null
|
||||
New-Item -ItemType Directory -Force $pshome\Traces | out-null
|
||||
}
|
||||
|
||||
if (Test-Path $logfile)
|
||||
|
||||
@@ -301,8 +301,8 @@ Describe 'Negative Parsing Tests' -Tags "CI" {
|
||||
ShouldBeParseError 'class C { [int]foo() { try { throw "foo"} catch [ArgumentException] {} catch {throw $_} } }' MethodHasCodePathNotReturn 15
|
||||
ShouldBeParseError 'class C { [int]foo() { try { throw "foo"} catch [ArgumentException] {return 1} catch {} } }' MethodHasCodePathNotReturn 15
|
||||
ShouldBeParseError 'class C { [int]foo() { while ($false) { return 1 } } }' MethodHasCodePathNotReturn 15
|
||||
ShouldBeParseError 'class C { [int]foo() { try { mkdir foo } finally { rm -rec foo } } }' MethodHasCodePathNotReturn 15
|
||||
ShouldBeParseError 'class C { [int]foo() { try { mkdir foo; return 1 } catch { } } }' MethodHasCodePathNotReturn 15
|
||||
ShouldBeParseError 'class C { [int]foo() { try { New-Item -ItemType Directory foo } finally { rm -rec foo } } }' MethodHasCodePathNotReturn 15
|
||||
ShouldBeParseError 'class C { [int]foo() { try { New-Item -ItemType Directory foo; return 1 } catch { } } }' MethodHasCodePathNotReturn 15
|
||||
ShouldBeParseError 'class C { [bool] Test() { if ($false) { return $true; } } }' MethodHasCodePathNotReturn 17
|
||||
|
||||
ShouldBeParseError 'class C { [int]$i; [void] foo() {$i = 10} }' MissingThis 33
|
||||
|
||||
@@ -498,7 +498,7 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" {
|
||||
$moduleDirectory = [io.path]::Combine($moduleRoot, $moduleName)
|
||||
$moduleFile = [io.path]::Combine($moduleDirectory, $moduleName + ".psm1")
|
||||
|
||||
mkdir $moduleDirectory 2> $null
|
||||
New-Item -ItemType Directory $moduleDirectory 2> $null
|
||||
|
||||
write-output '
|
||||
function ModuleFunction1
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ try
|
||||
|
||||
$modulePathName = "modulePath_$(Get-Random -Max 9999)"
|
||||
$modulePath = Join-Path $testdrive $modulePathName
|
||||
mkdir $modulePath
|
||||
New-Item -ItemType Directory $modulePath
|
||||
$trustedModuleFile = Join-Path $modulePath "T1TestModule_System32.psm1"
|
||||
$script | Out-File -FilePath $trustedModuleFile
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,13 +27,13 @@ try
|
||||
|
||||
$trustedModuleName1 = "TrustedModule$(Get-Random -Max 999)_System32"
|
||||
$trustedModulePath1 = Join-Path $TestDrive $trustedModuleName1
|
||||
mkdir $trustedModulePath1
|
||||
New-Item -ItemType Directory $trustedModulePath1
|
||||
$trustedModuleFilePath1 = Join-Path $trustedModulePath1 ($trustedModuleName1 + ".psm1")
|
||||
$trustedModuleManifestPath1 = Join-Path $trustedModulePath1 ($trustedModuleName1 + ".psd1")
|
||||
|
||||
$trustedModuleName2 = "TrustedModule$(Get-Random -Max 999)_System32"
|
||||
$trustedModulePath2 = Join-Path $TestDrive $trustedModuleName2
|
||||
mkdir $trustedModulePath2
|
||||
New-Item -ItemType Directory $trustedModulePath2
|
||||
$trustedModuleFilePath2 = Join-Path $trustedModulePath2 ($trustedModuleName2 + ".psm1")
|
||||
|
||||
$trustedModuleScript1 = @'
|
||||
|
||||
Reference in New Issue
Block a user