leafac / caxa

📦 Package Node.js applications into executable binaries 📦
https://npm.im/caxa
699 stars 34 forks source link

Current working directory on macos not per documentation #70

Closed sjscotti closed 11 months ago

sjscotti commented 1 year ago

Hi! caxa is working great to package up node.js apps using puppeteer, so I'll start off with giving you kudos for that great capability. However, I believe the documentation at https://github.com/leafac/caxa#the-current-working-directory is incorrect for macos - at least when packaging as a .app file. It works as described on Windows 10 packaged as a .exe file, but on macos, the current working directory when you click on the app is the home directory (i.e., the directory you are in when you do a cd ~ in the terminal ). I inspected it with process.cwd() as you suggested and verified this. To have the working directory be where the app is installed I inserted this code in it...

const process = require('node:process');
const path = require('node:path'); 
const parrrent = path.resolve(__dirname, '../../../..'); 
process.chdir(parrrent); // parrrent is now the current working folder
console.log('Current Working Directory is: ', parrrent);

There may be a more direct way to accomplish this, but adding this code did what I needed.

leafac commented 11 months ago

Hi @sjscotti,

Thanks for using caxa and for the nice words. As far as I understand, that’s how macOS works: Application Bundles (.app) always have a working directory of your home directory. I’m not aware of any way of changing this behavior.

In any case, I’ve been thinking about the broad strategy employed by caxa and concluded that there is a better way to solve the problem. Notably, it does not include the ability to create .apps. I hope it can still be useful to you anyway.

It’s a different enough approach that I think it deserves a new name, and it’s part of a bigger toolset that I’m building, which I call Radically Straightforward · Package.

I’m deprecating caxa and archiving this repository. I invite you to continue the conversation in Radically Straightforward’s issues.

Best.