Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Dec 11, 2024
1 parent 8be266d commit cb3e56a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
15 changes: 14 additions & 1 deletion src/Foundation/Console/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,24 @@ abstract class Action
*/
protected function pathLocation(string $path): string
{
$packagePath = package_path();

if (! \is_null($this->workingPath)) {
$path = str_replace(rtrim($this->workingPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR, '', $path);

$prefix = match ($this->workingPath) {
app()->basePath() => '@laravel',
$packagePath => '.',
default => '@'
};

return implode('/', [$prefix, ltrim($path, '/')]);
}

$path = str_replace(package_path(), '', $path);

if (str_starts_with($path, $packagePath)) {
return sprintf('./%s', ltrim(str_replace($packagePath, '', $path), '/'));
}

return $path;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Foundation/Console/CreateSqliteDbCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function it_can_generate_database_using_command()
$this->assertFalse(file_exists(database_path('database.sqlite')));

$this->artisan('package:create-sqlite-db')
->expectsOutputToContain('File [database/database.sqlite] generated')
->expectsOutputToContain('File [@laravel/database/database.sqlite] generated')
->assertOk();

$this->assertTrue(file_exists(database_path('database.sqlite')));
Expand All @@ -49,7 +49,7 @@ public function it_cannot_generate_database_using_command_when_database_already_
$this->assertTrue(file_exists(database_path('database.sqlite')));

$this->artisan('package:create-sqlite-db')
->expectsOutputToContain('File [database/database.sqlite] already exists')
->expectsOutputToContain('File [@laravel/database/database.sqlite] already exists')
->assertOk();
});
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Foundation/Console/DropSqliteDbCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function it_can_drop_database_using_command()
$this->assertTrue(file_exists(database_path('database.sqlite')));

$this->artisan('package:drop-sqlite-db')
->expectsOutputToContain('File [database/database.sqlite] has been deleted')
->expectsOutputToContain('File [@laravel/database/database.sqlite] has been deleted')
->assertOk();

$this->assertFalse(file_exists(database_path('database.sqlite')));
Expand All @@ -49,7 +49,7 @@ public function it_cannot_drop_database_using_command_when_database_doesnt_exist
$this->assertFalse(file_exists(database_path('database.sqlite')));

$this->artisan('package:drop-sqlite-db')
->expectsOutputToContain('File [database/database.sqlite] doesn\'t exists')
->expectsOutputToContain('File [@laravel/database/database.sqlite] doesn\'t exists')
->assertOk();
});
}
Expand Down

0 comments on commit cb3e56a

Please sign in to comment.