Skip to content

Commit 0ae949f

Browse files
committed
use env and config for auto opening in ide
1 parent be8d481 commit 0ae949f

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

config/generators.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
* is used. Have to implement Webfactor\Laravel\Generators\Contracts\OpenIdeInterface.
2323
*/
2424
'ides' => [
25-
'pstorm' => Webfactor\Laravel\Generators\Recipes\PhpStormOpener::class,
26-
'sublime' => Webfactor\Laravel\Generators\Recipes\SublimeOpener::class,
27-
'vscode' => Webfactor\Laravel\Generators\Recipes\VSCodeOpener::class,
25+
'phpstorm' => Webfactor\Laravel\Generators\Recipes\PhpStormOpener::class,
26+
'pstorm' => Webfactor\Laravel\Generators\Recipes\PhpStormOpener::class,
27+
'sublime' => Webfactor\Laravel\Generators\Recipes\SublimeOpener::class,
28+
'vscode' => Webfactor\Laravel\Generators\Recipes\VSCodeOpener::class,
2829
],
2930

3031
'naming' => [

src/Services/OpenIdeService.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,27 @@ class OpenIdeService extends ServiceAbstract implements ServiceInterface
99
{
1010
public function call()
1111
{
12-
if (!$ide = $this->command->option('ide')) {
13-
return;
12+
if ($ide = $this->command->option('ide')) {
13+
return $this->openInIde($ide);
14+
}
15+
16+
if ($ide = env('APP_EDITOR')) {
17+
return $this->openInIde($ide);
18+
}
19+
20+
if ($ide = config('app.editor')) {
21+
return $this->openInIde($ide);
1422
}
23+
}
1524

25+
protected function openInIde($ide)
26+
{
1627
if ($ideClass = config('webfactor.generators.ides.' . $ide)) {
1728
(new $ideClass($this->command->filesToBeOpened))->open();
29+
30+
return;
1831
}
32+
33+
$this->command->error('There is no opener class for ide <comment>' . $ide . '</comment>');
1934
}
2035
}

0 commit comments

Comments
 (0)