2 namespace Drush\Config;
4 use Consolidation\Config\Util\ConfigOverlay;
5 use Symfony\Component\Filesystem\Exception\IOException;
6 use Symfony\Component\Filesystem\Filesystem;
7 use Webmozart\PathUtil\Path;
10 * Accessors for common Drush config keys.
12 class DrushConfig extends ConfigOverlay
16 return $this->get('env.cwd');
19 public function home()
21 return $this->get('env.home');
24 public function user()
26 return $this->get('env.user');
29 public function isWindows()
31 return $this->get('env.is-windows');
36 return $this->get('env.tmp');
39 public function cache()
42 $this->get('drush.paths.cache-directory'),
43 Path::join($this->home(), '.drush/cache'),
44 Path::join($this->tmp(), 'drush-' . $this->user() . '/cache'),
47 $fs = new Filesystem();
48 foreach (array_filter($candidates) as $candidate) {
50 $fs->mkdir($candidate);
52 } catch (IOException $ioException) {
53 // Do nothing. Jump to the next candidate.
56 throw new \Exception('Cannot create the Drush cache directory. Tried next candidates: ' . implode(', ', $candidates));