refactor(core): Rewrite and separate path-related functions to system.ps1#5836
refactor(core): Rewrite and separate path-related functions to system.ps1#5836
system.ps1#5836Conversation
d7f0580 to
6a3fbed
Compare
- `strip_path()` -> `Find-Path()` - `ensure_in_path()`/`add_first_in_path()` -> `Add-Path()` - `remove_from_path()` -> `Remove-Path()`
7241009 to
e88260e
Compare
e88260e to
5645402
Compare
system.ps1
| } | ||
|
|
||
| function strip_path($orig_path, $dir) { | ||
| Show-DeprecatedWarning $MyInvocation 'Find-Path' |
There was a problem hiding this comment.
I realize there are references of this function in some manifests, but I think this function should not be provided and used outside of the core (though I know there is impossible to hide a function based on the current corebase, all functions are exposed, which I dislike).
What they really want is a way to manipulate $env:PATH-like environment variables, something like Add-PathLikeEnvVar and Remove-PathLikeEnvVar (further abstraction of Add-Path and Remove-Path). This is useful because there are many operations on $env:PATH-like env vars, plus the proposal of $env:SCOOP_PATH is staging. Add-Path and Remove-Path are $env:PATH-specific and may not be much useful if/after $env:SCOOP_PATH is implemented.
There was a problem hiding this comment.
Maybe a refactoring into modules could be done if I have time.
For now, keep the deprecated warning of strip_path, and will remove outside use after this PR goes to main.
Description
Ed. Separate part of isolate PATH to #5840, this PR is for refactoring now.
Use config optionuse_isolated_pathto separate Scoop apps PATH toSCOOP_PATH, and just add%SCOOP_PATH%to$env:Pathwhen install app withenv_add_pathfirst time.Motivation and Context
What the commits do:
ensure_robocopy_in_path()system.ps1core.ps1:Publish-Env(),env(),search_in_path(),ensure_in_path(),strip_path(),add_first_in_path(),remove_from_path()system.ps1importingenv()toGet-EnvVar()andSet-EnvVar()search_in_path()Get-Command().Sourcestrip_path()->Find-Path()ensure_in_path()/add_first_in_path()->Add-Path()ensure_in_path()is only used in shim creation-Forceto forcedly add a path in the first position asadd_first_in_path()Add-Path()supports%remove_from_path()->Remove-Path()How Has This Been Tested?
Passed all Scoop tests.
Checklist:
developbranch.