mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-09 10:04:45 +02:00
Improve usage of test-path
This commit is contained in:
parent
a39508856b
commit
7a57971d0c
@ -14,7 +14,7 @@ try {
|
|||||||
$User = $(whoami)
|
$User = $(whoami)
|
||||||
$Line = "$Time,$User,$Text"
|
$Line = "$Time,$User,$Text"
|
||||||
|
|
||||||
if (-not(test-path "$Path")) {
|
if (-not(test-path "$Path" -pathType leaf)) {
|
||||||
write-output "Time,User,Text" > "$Path"
|
write-output "Time,User,Text" > "$Path"
|
||||||
}
|
}
|
||||||
write-output $Line >> "$Path"
|
write-output $Line >> "$Path"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (test-path "/sys/class/thermal/thermal_zone0/temp") {
|
if (test-path "/sys/class/thermal/thermal_zone0/temp" -pathType leaf) {
|
||||||
[int]$IntTemp = get-content "/sys/class/thermal/thermal_zone0/temp"
|
[int]$IntTemp = get-content "/sys/class/thermal/thermal_zone0/temp"
|
||||||
$Temp = [math]::round($IntTemp / 1000.0, 1)
|
$Temp = [math]::round($IntTemp / 1000.0, 1)
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$Path = "$HOME/Memos.csv"
|
$Path = "$HOME/Memos.csv"
|
||||||
if (test-path "$Path") {
|
if (test-path "$Path" -pathType leaf) {
|
||||||
write-progress "Reading $Path ..."
|
write-progress "Reading $Path ..."
|
||||||
$Table = import-csv "$Path"
|
$Table = import-csv "$Path"
|
||||||
write-progress -completed "Reading $Path"
|
write-progress -completed "Reading $Path"
|
||||||
|
@ -9,7 +9,7 @@ param($RepoDir = "$PWD")
|
|||||||
|
|
||||||
function MakeDir { param($Path)
|
function MakeDir { param($Path)
|
||||||
$DirName = (get-item "$Path").Name
|
$DirName = (get-item "$Path").Name
|
||||||
if (test-path "$Path/CMakeLists.txt") {
|
if (test-path "$Path/CMakeLists.txt" -pathType leaf) {
|
||||||
"⏳ Building 📂$DirName using CMakeLists.txt to subfolder BuildFiles..."
|
"⏳ Building 📂$DirName using CMakeLists.txt to subfolder BuildFiles..."
|
||||||
if (-not(test-path "$Path/BuildFiles/" -pathType container)) {
|
if (-not(test-path "$Path/BuildFiles/" -pathType container)) {
|
||||||
& mkdir "$Path/BuildFiles/"
|
& mkdir "$Path/BuildFiles/"
|
||||||
@ -25,7 +25,7 @@ function MakeDir { param($Path)
|
|||||||
& make test
|
& make test
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/configure") {
|
} elseif (test-path "$Path/configure" -pathType leaf) {
|
||||||
"⏳ Building 📂$DirName using 'configure'..."
|
"⏳ Building 📂$DirName using 'configure'..."
|
||||||
set-location "$Path/"
|
set-location "$Path/"
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ function MakeDir { param($Path)
|
|||||||
& make -j4
|
& make -j4
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/autogen.sh") {
|
} elseif (test-path "$Path/autogen.sh" -pathType leaf) {
|
||||||
"⏳ Building 📂$DirName using 'autogen.sh'..."
|
"⏳ Building 📂$DirName using 'autogen.sh'..."
|
||||||
set-location "$Path/"
|
set-location "$Path/"
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ function MakeDir { param($Path)
|
|||||||
& make -j4
|
& make -j4
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/build.gradle") {
|
} elseif (test-path "$Path/build.gradle" -pathType leaf) {
|
||||||
"⏳ Building 📂$DirName using build.gradle..."
|
"⏳ Building 📂$DirName using build.gradle..."
|
||||||
set-location "$Path"
|
set-location "$Path"
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ function MakeDir { param($Path)
|
|||||||
& gradle test
|
& gradle test
|
||||||
if ($lastExitCode -ne "0") { throw "'gradle test' has failed" }
|
if ($lastExitCode -ne "0") { throw "'gradle test' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/Imakefile") {
|
} elseif (test-path "$Path/Imakefile" -pathType leaf) {
|
||||||
"⏳ Building 📂$DirName using Imakefile..."
|
"⏳ Building 📂$DirName using Imakefile..."
|
||||||
set-location "$RepoDir/"
|
set-location "$RepoDir/"
|
||||||
|
|
||||||
@ -65,14 +65,14 @@ function MakeDir { param($Path)
|
|||||||
& make -j4
|
& make -j4
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/Makefile") {
|
} elseif (test-path "$Path/Makefile" -pathType leaf) {
|
||||||
"⏳ Building 📂$DirName using Makefile..."
|
"⏳ Building 📂$DirName using Makefile..."
|
||||||
set-location "$Path"
|
set-location "$Path"
|
||||||
|
|
||||||
& make -j4
|
& make -j4
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/compile.sh") {
|
} elseif (test-path "$Path/compile.sh" -pathType leaf) {
|
||||||
"⏳ Building 📂$DirName using 'compile.sh'..."
|
"⏳ Building 📂$DirName using 'compile.sh'..."
|
||||||
set-location "$Path/"
|
set-location "$Path/"
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ function MakeDir { param($Path)
|
|||||||
& make -j4
|
& make -j4
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/attower/src/build/DevBuild/build.bat") {
|
} elseif (test-path "$Path/attower/src/build/DevBuild/build.bat" -pathType leaf) {
|
||||||
"⏳ Building 📂$DirName using build.bat ..."
|
"⏳ Building 📂$DirName using build.bat ..."
|
||||||
set-location "$Path/attower/src/build/DevBuild/"
|
set-location "$Path/attower/src/build/DevBuild/"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user