Skip to content

Commit

Permalink
feat: rewrite path setting
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Jun 8, 2024
1 parent 6efdfad commit 3aac4b8
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/playbook/Configuration/atlas/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ actions:
- !powerShell:
wait: true
command: >-
$modulesPath = """$([Environment]::GetFolderPath('Windows'))\AtlasModules""";
function Add-ToPath ([array]$Paths) {
$machine = [System.EnvironmentVariableTarget]::Machine;
$seperator = [IO.Path]::PathSeparator;
$Paths | ForEach-Object {
if (!(Test-Path $_ -PathType Container)) {
Write-Error """Path '$_' doesn't exist as a container."""
}
};
function AddToVar($env, $value) {
$a = [IO.Path]::PathSeparator;
$b = [System.EnvironmentVariableTarget]::Machine;
$c = [Environment]::GetEnvironmentVariables($b);
$newPath = @();
$newPath += [Environment]::GetEnvironmentVariable('PATH', $machine) -split $seperator;
if ($newPath.Count -eq 0) { Write-Warning 'The PATH variable is currently empty.' };
$newPath += $Paths;
$newPath = $newPath | Where-Object { $_ } | Select-Object -Unique;
[Environment]::SetEnvironmentVariable($env,
("""$($c.'Path');$value""" -replace ';',"""$a"""),
$b);
[Environment]::SetEnvironmentVariable('PATH', """$($newPath -join $seperator)""", $machine);
};
AddToVar 'Path' """$modulesPath;$modulesPath\Apps;$modulesPath\Other;$modulesPath\Tools;$modulesPath\Scripts""";
$modulesPath = """$([Environment]::GetFolderPath('Windows'))\AtlasModules""";
Add-ToPath """$modulesPath""", """$modulesPath\Apps""", """$modulesPath\Other""", """$modulesPath\Tools""", """$modulesPath\Scripts""";
################ NO LOCAL BUILD ################

Expand Down

0 comments on commit 3aac4b8

Please sign in to comment.