Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Drivers/Electron/ElectronServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}

Expand Down
19 changes: 19 additions & 0 deletions tests/Electron/ElectronPathTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Native\Desktop\Drivers\Electron\ElectronServiceProvider;
use Native\Desktop\Support\Composer;
use Symfony\Component\Filesystem\Filesystem;

afterEach(fn () => (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'));
});