1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 00:20:08 +01:00

prune on every command

This commit is contained in:
Taylor Otwell
2016-05-05 01:18:48 -05:00
parent 5d5438dc12
commit 2cc1b4082e
3 changed files with 37 additions and 6 deletions

View File

@@ -37,15 +37,29 @@ public static function link($name)
*/
public static function unlink($name)
{
if (! file_exists($path = $_SERVER['HOME'].'/.valet/Sites/'.$name)) {
return false;
}
@unlink($path);
quietly('rm '.$_SERVER['HOME'].'/.valet/Sites/'.$name);
return true;
}
/**
* Remove all broken symbolic links.
*
* @return void
*/
public static function pruneLinks()
{
foreach (scandir($_SERVER['HOME'].'/.valet/Sites') as $file) {
if (in_array($file, ['.', '..'])) {
continue;
}
if (is_link($linkPath = $_SERVER['HOME'].'/.valet/Sites/'.$file) && ! file_exists($linkPath)) {
quietly('rm '.$linkPath);
}
}
}
/**
* Get all of the log files for all sites.
*

13
valet
View File

@@ -15,8 +15,19 @@ then
sudo php $DIR/valet.php $@
elif [[ $1 = "share" ]]
then
HOST=${PWD##*/}
for linkname in ~/.valet/Sites/*; do
RESOLVED_LINK=$(readlink $linkname)
if [[ $RESOLVED_LINK = $PWD ]]
then
HOST=${linkname##*/}
fi
done
bash $DIR/fetch-share-url.sh &
$DIR/bin/ngrok http -host-header=rewrite ${PWD##*/}.dev:80
$DIR/bin/ngrok http -host-header=rewrite $HOST.dev:80
else
php $DIR/valet.php $@
fi

View File

@@ -16,6 +16,12 @@
*/
$app = new Application('Laravel Valet', 'v1.0.0');
/**
* Prune missing directories on every command.
*/
Valet\Configuration::prune();
Valet\Site::pruneLinks();
/**
* Allow Valet to be run more conveniently by allowing the Node proxy to run password-less sudo.
*/