Closed navneetgarg123 closed 7 years ago
There's no equivalent to Rake.original_dir
in the Jake API, however Node itself can provide that info. There are a few options, each with different caveats, but they should cover all needs:
__dirname
: Returns the path to the Jakefile that is currently executing. This means if the file is in another directory (using the -f
flag or it's in jakelib
, for instance), that directory will be returned - not the directory jake
was called from.process.cwd()
: Returns the path that Jake was executed from. However, if the --directory
flag was used, that directory will be returned. Sometimes desirable, sometimes not.process.env['PWD']
: This will return the directory Jake was actually called from, even if the --directory
flag was used or the file resides in another directory.Given that these cover all use cases and are idiomatic Node, I'd lean towards not expanding the Jake API to include that info and encourage people use the underlying Node APIs.
A very well put together response. Thank you! I agree - no need to extend the API if it's part of core Node.
is there an equivalent to rake's
Rake.original_dir
?i.e. is there a way to know the calling directory of the jake invocation?