How can you get the path to a user's home directory in Clojurescript running on Node?

122 views Asked by At

You can't use ~ in paths for NodeJS functions because that's a bash-specific thing. So how do you get the path to a user's home directory in Clojurescript (on Node)?

1

There are 1 answers

0
michaelrbock On
(def os (node/require "os"))

(.homedir os)

And to combine it with an additional path:

(def path (node/require "path"))

(.join path (.homedir os) "/directory/file.txt")