Skip to content

Commit cb1f21c

Browse files
committed
Better error reporting in generator
1 parent 4291f9c commit cb1f21c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Console/WidgetMakeCommand.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Arrilot\Widgets\Console;
44

5+
use RuntimeException;
6+
use Illuminate\Support\Str;
57
use Illuminate\Console\GeneratorCommand;
68
use Symfony\Component\Console\Input\InputOption;
79

@@ -139,7 +141,13 @@ protected function replaceView($stub)
139141
*/
140142
protected function getDefaultNamespace($rootNamespace)
141143
{
142-
return config('laravel-widgets.default_namespace', $rootNamespace.'\Widgets');
144+
$namespace = config('laravel-widgets.default_namespace', $rootNamespace.'\Widgets');
145+
146+
if (!Str::startsWith($namespace, $rootNamespace)) {
147+
throw new RuntimeException("You can not use the generator if the default namespace ($namespace) does not start with application namespace ($rootNamespace)");
148+
}
149+
150+
return $namespace;
143151
}
144152

145153
/**

0 commit comments

Comments
 (0)