diff --git a/CHANGELOG.md b/CHANGELOG.md index 174a29e64..fa9d1c431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All Notable changes to `laravel-modules` will be documented in this file. - A `--migration` flag to the `module:make-model` command to generate the migration file with a model - Factories are now also defined in the master service providers. This is used in the `module:make` command without the `--plain` flag, or using `module:make-provider` with the `--master` flag. +- `module_path()` helper function. ## Changed diff --git a/composer.json b/composer.json index 81f155f66..32ae487ab 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,10 @@ "autoload": { "psr-4": { "Nwidart\\Modules\\": "src" - } + }, + "files": [ + "src/helpers.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/src/helpers.php b/src/helpers.php new file mode 100644 index 000000000..02b3a3f0e --- /dev/null +++ b/src/helpers.php @@ -0,0 +1,10 @@ +find($name); + + return $module->getPath(); + } +} diff --git a/tests/HelpersTest.php b/tests/HelpersTest.php new file mode 100644 index 000000000..0e33c801f --- /dev/null +++ b/tests/HelpersTest.php @@ -0,0 +1,35 @@ +modulePath = base_path('modules/Blog'); + $this->finder = $this->app['files']; + $this->artisan('module:make', ['name' => ['Blog']]); + } + + public function tearDown() + { + $this->finder->deleteDirectory($this->modulePath); + parent::tearDown(); + } + + /** @test */ + public function it_finds_the_module_path() + { + $this->assertTrue(str_contains(module_path('Blog'), 'modules/Blog')); + } +}