diff --git a/src/Drivers/Electron/ElectronServiceProvider.php b/src/Drivers/Electron/ElectronServiceProvider.php index dc7f9e75..fb722b59 100644 --- a/src/Drivers/Electron/ElectronServiceProvider.php +++ b/src/Drivers/Electron/ElectronServiceProvider.php @@ -21,10 +21,8 @@ class ElectronServiceProvider extends PackageServiceProvider public static function electronPath(string $path = '') { // Will use the published electron project, or fallback to the vendor default - $publishedProjectPath = base_path("nativephp/electron/{$path}"); - - return file_exists("{$publishedProjectPath}/package.json") - ? $publishedProjectPath + return file_exists(base_path('nativephp/electron/package.json')) + ? base_path("nativephp/electron/{$path}") : Composer::desktopPackagePath("resources/electron/{$path}"); } diff --git a/tests/Electron/ElectronPathTest.php b/tests/Electron/ElectronPathTest.php new file mode 100644 index 00000000..a55b6794 --- /dev/null +++ b/tests/Electron/ElectronPathTest.php @@ -0,0 +1,19 @@ + (new Filesystem)->remove(base_path('nativephp'))); + +it('resolves sub-paths inside the published electron project', function () { + (new Filesystem)->dumpFile(base_path('nativephp/electron/package.json'), '{}'); + + expect(ElectronServiceProvider::electronPath('node_modules/electron/dist/Electron.app/Contents/Info.plist')) + ->toBe(base_path('nativephp/electron/node_modules/electron/dist/Electron.app/Contents/Info.plist')); +}); + +it('falls back to the vendor electron project when none is published', function () { + expect(ElectronServiceProvider::electronPath('package.json')) + ->toBe(Composer::desktopPackagePath('resources/electron/package.json')); +});