diff --git a/README.md b/README.md index 90ca8c5..fb443cf 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ That's it! You're ready to go. We've provided an `laravel-examples.spec.ts` spec yarn playwright test ``` - ## Credits - [Yoann Frommelt](https://www.linkedin.com/in/yoannfrommelt/) diff --git a/src/PlaywrightServiceProvider.php b/src/PlaywrightServiceProvider.php index 614b898..5fd2f04 100644 --- a/src/PlaywrightServiceProvider.php +++ b/src/PlaywrightServiceProvider.php @@ -9,27 +9,36 @@ class PlaywrightServiceProvider extends ServiceProvider { public function boot() { - if ($this->app->environment('production')) { - return; - } - - $this->addRoutes(); + $this->mergeConfigFrom(__DIR__ . '/config/playwright.php', 'playwright'); if ($this->app->runningInConsole()) { $this->publishes([ - __DIR__.'/routes/playwright.php' => base_path('routes/playwright.php'), + __DIR__ . '/routes/playwright.php' => base_path('routes/playwright.php'), + __DIR__ . '/config/playwright.php' => base_path('config/playwright.php'), ]); $this->commands([ PlaywrightBoilerplateCommand::class, ]); } + + if ( + $this->app->environment("production") || + !in_array( + $this->app->environment(), + config("playwright.allowed_environments") + ) + ) { + return; + } + + $this->addRoutes(); } protected function addRoutes() { Route::namespace('') ->middleware('web') - ->group(__DIR__.'/routes/playwright.php'); + ->group(__DIR__ . '/routes/playwright.php'); } } diff --git a/src/config/playwright.php b/src/config/playwright.php new file mode 100644 index 0000000..6104dc0 --- /dev/null +++ b/src/config/playwright.php @@ -0,0 +1,5 @@ + ["local", "testing", "playwright"], +];