Skip to content

Commit

Permalink
Add HOME directory constant
Browse files Browse the repository at this point in the history
  • Loading branch information
uberhacker committed Jan 25, 2017
1 parent bc7ea96 commit 0e61714
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/Commands/SiteMountCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@
use Pantheon\Terminus\Site\SiteAwareTrait;
use Pantheon\Terminus\Collections\Sites;

// Get HOME directory.
define('HOME', getenv('HOME'));

// Is the operating system is MS Windows?
$windows = (php_uname('s') == 'Windows NT');

// Determine the directory separator.
$slash = $windows ? '\\' : '/';
define('SLASH', $slash);

// Determine the default mount location.
$temp_dir = $windows ? '\\Temp' : '/tmp';
define('TEMP_DIR', $temp_dir);

/**
* Class SiteMountCommand
* Mounts/unmounts the site environment via SSHFS.
Expand All @@ -17,17 +31,6 @@ class SiteMountCommand extends TerminusCommand implements SiteAwareInterface

use SiteAwareTrait;

// Is the operating system is MS Windows?
$windows = (php_uname('s') == 'Windows NT');

// Determine the directory separator.
$slash = $windows ? '\\' : '/';
define('SLASH', $slash);

// Determine the default mount location.
$temp_dir = $windows ? '\\Temp' : '/tmp';
define('TEMP_DIR', $temp_dir);

/**
* Mounts the site environment via SSHFS.
*
Expand Down Expand Up @@ -58,7 +61,7 @@ public function mount($site_env = '', $options = ['dir' => TEMP_DIR])
$port = $connection_info['port'];

// Determine the mount location.
$mount = $options['dir'] . SLASH . $site_env;
$mount = str_replace('~', HOME, $options['dir']) . SLASH . $site_env;

// Create the mount directory if it doesn't exist.
$command = "if [ ! -d {$mount} ]; then mkdir {$mount}; fi";
Expand Down Expand Up @@ -102,7 +105,7 @@ public function unmount($site_env = '', $options = ['dir' => TEMP_DIR])
}

// Determine the mount location.
$mount = $options['dir'] . SLASH . $site_env;
$mount = str_replace('~', HOME, $options['dir']) . SLASH . $site_env;

// Check if the directory exists.
if (!file_exists($mount)) {
Expand Down

0 comments on commit 0e61714

Please sign in to comment.