Skip to content

Commit

Permalink
Enabled shimming of external applications
Browse files Browse the repository at this point in the history
  • Loading branch information
excitoon committed Mar 1, 2018
1 parent fc5823e commit da15cc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 9 additions & 0 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ powershell -noprofile -ex unrestricted `"& '$resolved_path' %args%;exit `$lastex
}
}

function search_in_path($target) {
$path = (env 'PATH' $false) + ";" + (env 'PATH' $true)
$path.split(';') | % {
if(test-path "$_\$target") {
return "$_\$target"
}
}
}

function ensure_in_path($dir, $global) {
$path = env 'PATH' $global
$dir = fullpath $dir
Expand Down
12 changes: 7 additions & 5 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,16 @@ function create_shims($manifest, $dir, $global, $arch) {
$target, $name, $arg = shim_def $_
write-output "Creating shim for '$name'."

# check valid bin
$bin = "$dir\$target"
if(!(is_in_dir $dir $bin)) {
abort "Error in manifest: bin '$target' is outside the app directory."
if(test-path "$dir\$target") {
$bin = "$dir\$target"
} elseif(test-path $target) {
$bin = $target
} else {
$bin = search_in_path $target
}
if(!(test-path $bin)) { abort "Can't shim '$target': File doesn't exist."}

shim "$dir\$target" $global $name (substitute $arg @{ '$dir' = $dir; '$original_dir' = $original_dir; '$persist_dir' = $persist_dir})
shim $bin $global $name (substitute $arg @{ '$dir' = $dir; '$original_dir' = $original_dir; '$persist_dir' = $persist_dir})
}
}

Expand Down

0 comments on commit da15cc3

Please sign in to comment.