mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
34 lines
961 B
PHP
34 lines
961 B
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
class ShareCurrentWorkingDirectoryCommand extends ShareCommand
|
|
{
|
|
protected $signature = 'share-cwd {host?} {--subdomain=} {--auth=}';
|
|
|
|
public function handle()
|
|
{
|
|
$this->input->setArgument('host', basename(getcwd()).'.'.$this->detectTld());
|
|
|
|
if (! $this->hasOption('subdomain')) {
|
|
$subdomain = str_replace('.', '_', basename(getcwd()));
|
|
$this->input->setOption('subdomain', $subdomain);
|
|
}
|
|
|
|
parent::handle();
|
|
}
|
|
|
|
protected function detectTld(): string
|
|
{
|
|
$valetConfigFile = $_SERVER['HOME'] ?? $_SERVER['USERPROFILE'].DIRECTORY_SEPARATOR.'.config'.DIRECTORY_SEPARATOR.'valet'.DIRECTORY_SEPARATOR.'config.json';
|
|
|
|
if (file_exists($valetConfigFile)) {
|
|
$valetConfig = json_decode(file_get_contents($valetConfigFile));
|
|
|
|
return $valetConfig->tld;
|
|
}
|
|
|
|
return config('expose.default_tld', 'test');
|
|
}
|
|
}
|