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:
24
src/Site.php
24
src/Site.php
@@ -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
13
valet
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user