Fix/module path resolution#38
Conversation
Automatic Self-Check - #38The details of our automated scan for your pull request are listed below. If our scan detected errors, they must be corrected before this pull request will be advanced to the review stage: AboutThis pull request includes the following information:
📄 test/module-resolution.jsCaution Errors must be fixed prior to a pull request being reviewed and accepted. ❌ 📄 notifiers/balloon.jsNote The file 📄 notifiers/notificationcenter.jsNote The file 📄 notifiers/toaster.jsNote The file This check was done automatically. Do NOT open a new PR for re-validation. Instead, to trigger this check again, make a change to your PR and wait a few minutes, or close and re-open it. |
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