How to get working directory in node-webkit


I've got a simple program that can be run from command line.
This program is for live preview of markdown files.
When i'm packaging the app with

cat $NW/nw marknow.nw > marknow

and running from different location:

./build/marknow ../relative/path/to/

I can't get current working directory.


is returning /tmp/something???

How can I get working directory in node-webkit? Directory from which ./build/marknow ../relative/path/to/ was called.

Best Solution

Another option you could try if the cwd doesn't seem to work is getting the execution directory with something like this:

var path = require('path');
var execPath = path.dirname( process.execPath );

This should get you the execution directory of the exe. cwd gets the temp directory because of how node-webkit handles opening the files from a temp directory on each run.