feat: Use DIR_ASSETS path to locate resource bundles (#47950)

* feat: Use DIR_ASSETS path to locate resource bundles

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* Use DIR_ASSETS for calculating ASAR relative paths

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* Add test to verify 'assets' matches parent dir of 'exe'

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* Add Mac-specific test for assets path (but it is failing)

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* test: Update app.getPath('assets') to expect an exception on Mac

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* docs: Update docs for 'assets' path to indicate that it's only available on Windows + Linux

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* fix: Don't define 'assets' mapping on macOS

Co-authored-by: Will Anderson <andersonw@dropbox.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Will Anderson <andersonw@dropbox.com>
This commit is contained in:
trop[bot] 2025-08-06 19:40:11 +02:00 committed by GitHub
commit 433f9f5e8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 27 additions and 10 deletions

View file

@ -1109,6 +1109,20 @@ describe('app module', () => {
expect(paths).to.deep.equal([true, true, true]);
});
if (process.platform === 'darwin') {
it('throws an error when trying to get the assets path on macOS', () => {
expect(() => {
app.getPath('assets' as any);
}).to.throw(/Failed to get 'assets' path/);
});
} else {
it('returns an assets path that is identical to the module path', () => {
const assetsPath = app.getPath('assets');
expect(fs.existsSync(assetsPath)).to.be.true();
expect(assetsPath).to.equal(path.dirname(app.getPath('module')));
});
}
it('throws an error when the name is invalid', () => {
expect(() => {
app.getPath('does-not-exist' as any);