I have created a small CLI tool in typescript and have achieved to create a .exe out of it with nexe. A new use case is to write out some files that are bundled within the application: Let's say my CLI tool provides the user with empty template files that the user can then fill out.
A sample command would be: myapp.exe --action export-templates --outdir path/to/some/dir
What shall happen now is that the CLI tool will export the template files that it contains to this location.
I have bundled the files already, see an excerpt of my package.json:
"scripts": {
"build": "npm run compile && nexe compiled/index.js --target windows-x64-10.16.0 --resource \"resources/**/*\""
}
I tried to access the files with:
const fileBuffer = fs.readFileSync(path.join('__dirname', `/templates/mytemplate.doc`));
However, I come up with an exception:
Error: ENOENT: no such file or directory, open 'C:\Users\Tom\compiled\templates\mytemplate.doc'
Can anyone tell me how to properly access the files inside my bundled .exe with fs?