-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(core): Rewrite and separate path-related functions to system.ps1
#5836
Conversation
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
lib/system.ps1
Outdated
} | ||
|
||
function strip_path($orig_path, $dir) { | ||
Show-DeprecatedWarning $MyInvocation 'Find-Path' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_path
to separate Scoop apps PATH toSCOOP_PATH
, and just add%SCOOP_PATH%
to$env:Path
when install app withenv_add_path
first time.Motivation and Context
What the commits do:
ensure_robocopy_in_path()
system.ps1
core.ps1
:Publish-Env()
,env()
,search_in_path()
,ensure_in_path()
,strip_path()
,add_first_in_path()
,remove_from_path()
system.ps1
importingenv()
toGet-EnvVar()
andSet-EnvVar()
search_in_path()
Get-Command().Source
strip_path()
->Find-Path()
ensure_in_path()
/add_first_in_path()
->Add-Path()
ensure_in_path()
is only used in shim creation-Force
to 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:
develop
branch.