-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18: Support homedir references (`~` or `$HOME`) in runtimeExecutable config r=Yatekii a=dbrgn This allows using paths like `~/.cargo/bin/probe-rs-debugger` instead of hardcoding your username. Co-authored-by: Danilo Bargen <mail@dbrgn.ch>
- Loading branch information
Showing
2 changed files
with
32 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as os from 'os'; | ||
|
||
/** | ||
* Replace references to the home directory in a path (either `~` or `$HOME`). | ||
* | ||
* This will only match paths at the start of the string, followed by a path | ||
* separator or by the end of the string. | ||
*/ | ||
export function replaceHome(path: string): string { | ||
const homeDir = os.homedir(); | ||
return homeDir ? path.replace(/^(~|\$HOME)(?=$|\/|\\)/, homeDir) : path; | ||
} |