Skip to content

Commit

Permalink
CLI-1191: Support XDG Base Dir
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Oct 31, 2023
1 parent b1a1914 commit 1cf96fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bin/acli
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ $input = new ArgvInput();
if (!getenv('HOME')) {
putenv('HOME=' . LocalMachineHelper::getHomeDir());
}
if (!getenv('ACLI_HOME')) {
putenv('ACLI_HOME=' . LocalMachineHelper::getConfigDir());
}
$kernel = new Kernel('prod', false);

// Handle a clear-kernel-cache pseudo command. This isn't implemented as a true console
Expand Down
2 changes: 1 addition & 1 deletion config/prod/services.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
parameters:
env(ACLI_REPO_ROOT): "%kernel.project_dir%"
app.data_dir: "%env(HOME)%/.acquia"
app.data_dir: "%env(ACLI_HOME)%"
app.project_dir: "%env(ACLI_REPO_ROOT)%"
app.ssh_dir: "%env(HOME)%/.ssh"
app.acli_config_filename: '.acquia-cli.yml'
Expand Down
12 changes: 12 additions & 0 deletions src/Helpers/LocalMachineHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ public static function getHomeDir(): string {
return $home;
}

public static function getConfigDir(): string {
$home = self::getHomeDir();
$legacyDir = Path::join($home, '.acquia');
if (file_exists($legacyDir)) {
return $legacyDir;
}
if ($xdgHome = getenv('XDG_CONFIG_HOME')) {
return Path::join($xdgHome, 'acquia');
}
return Path::join($home, '.config', 'acquia');
}

/**
* Get the project root directory for the working directory.
*
Expand Down

0 comments on commit 1cf96fd

Please sign in to comment.