Skip to content
This repository was archived by the owner on Aug 16, 2023. It is now read-only.

Check powershell version number #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/PlatformEngines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ function probe_cmd(cmd::Cmd; verbose::Bool = false)
@info("Probing $(cmd.exec[1]) as a possibility...")
end
try
success(cmd)
if verbose
res = success(cmd)
if res && verbose
@info(" Probe successful for $(cmd.exec[1])")
end
return true
return res
catch
return false
end
Expand Down Expand Up @@ -260,17 +260,17 @@ function probe_platform_engines!(;verbose::Bool = false)
\$webclient.DownloadFile("$url", "$path")
"""
replace(webclient_code, "\n" => " ")
return `$psh_path -NoProfile -Command "$webclient_code"`
return `$psh_path -Version 3 -NoProfile -Command "$webclient_code"`
end
end

# We want to search both the `PATH`, and the direct path for powershell
psh_path = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell"
prepend!(download_engines, [
(`$psh_path -Command ""`, psh_download(psh_path))
(`$psh_path -Version 3 -NoProfile -Command ""`, psh_download(psh_path))
])
prepend!(download_engines, [
(`powershell -Command ""`, psh_download(`powershell`))
(`powershell -Version 3 -NoProfile -Command ""`, psh_download(`powershell`))
])

# We greatly prefer `7z` as a compression engine on Windows
Expand Down Expand Up @@ -369,7 +369,7 @@ function probe_platform_engines!(;verbose::Bool = false)
end

for path in sh_engines
if probe_cmd(`$path --help`; verbose=verbose)
if probe_cmd(`$path -c ""`; verbose=verbose)
gen_sh_cmd = (cmd) -> `$path -c $cmd`
if verbose
@info("Found sh engine $(path.exec[1])")
Expand All @@ -385,7 +385,11 @@ function probe_platform_engines!(;verbose::Bool = false)
if !download_found
errmsg *= "No download engines found. We looked for: "
errmsg *= join([d[1].exec[1] for d in download_engines], ", ")
errmsg *= ". Install one and ensure it is available on the path.\n"
errmsg *= ". Install one and ensure it is available on the path.\n"
if Sys.iswindows()
errmsg *= "Ensure Windows Management Framework 3.0 or later "
errmsg *= "is installed and that Windows PowerShell can be started.\n"
end
end

if !compression_found
Expand Down