Fix/module path resolution #38
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Issue
While attempting to use this module in a vscode extension, there was a path resolution bug where
__dirnameresolved to the base extension folder instead of the module itself, thus causing the notifications to not work correctly since the binaries (ntfytoast.exe,notifu.exe, andterminal-notifier) couldn't be found.The Solution
Replaced
path.resolve()andpath.join()withrequire.resolve()for all binaries that used relative paths. Withrequire.resolve(), it can correctly handle the relative path without the need for__dirname.This should also help with the webpack, esbuild, and electron configurations as these should properly resolve without needing to set the electron configuration. (Though I didn't fix the __filename reference since it was unrelated to my issue.)
Changes
notifiers/baloon.jsrequire.resolve().exeback to the filepath for the 64-bit suffix handling.notifiers/notificationcenter.jsrequire.resolve()notifiers/toaster.jsrequire.resolve().execoncatenation since resolve includes the full extension.test/module-resolution.js- A test suite of 14 tests that should cover:__dirname: trueconfig)path.resolve(__dirname)pattern is removed.exefiles.Testing