From 534431ff93f1acb0c68a8e54aec95bb87505908b Mon Sep 17 00:00:00 2001 From: Sascha Deus Date: Thu, 17 Sep 2026 11:38:40 +0200 Subject: [PATCH] fix(electron): resolve sub-paths inside published electron project --- .../Electron/ElectronServiceProvider.php | 6 ++---- tests/Electron/ElectronPathTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/Electron/ElectronPathTest.php 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')); +});