Skip to content

Commit

Permalink
check absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Jul 2, 2021
1 parent 21304c4 commit 58f1dcf
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Commands/StartRoadRunnerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,33 @@ protected function writeServerStateFile(
*/
protected function configPath()
{
if (! $this->option('config-path')) {
$path = $this->option('config-path');
if (! $path) {
touch(base_path('.rr.yaml'));
return base_path('.rr.yaml');
}
return $this->option('config-path');

if (! $this->isAbsolutePath($path)) {
return base_path($path);
}
return $path;
}

/**
* Check if path is absolute
* Example:
* '.rr.yaml' returns false
* '~/.rr.yaml' returns false
* '/.rr.yaml' returns true
* './.rr.yaml' returns false
*
* @return bool
*/
protected function isAbsolutePath($path)
{
return $path[0] === DIRECTORY_SEPARATOR
|| preg_match('~\A[A-Z]:(?![^/\\\\])~i', $path) > 0;
}
/**
* Get the number of workers that should be started.
*
Expand Down

0 comments on commit 58f1dcf

Please sign in to comment.