So I have written a short node module (module1) as a wrapper for a binary (.exe) that can be called via command line.
This is how I get the path to the binary to execute the .exe with execFilePromised
.
It works in my module1.
const __dirname = fs.realpathSync('.');
const mpqEditorLocation = path.resolve(__dirname, './mpq/MPQEditor.exe');
Problem:
When I import module1 with npm link ../<module1>
into another node project the path is not correctly set to the .exe
since this resides in my node_modules
folder and not at <otherproject>/mpq/MPQEditor.exe
How can I make the __dirname
relative to the actual file not the project execution directory?