Is there a way to load from the current directory in a package?


I tried coffeescript like this:

out = fs.readFileSync "./intro.php"

Where intro.php is in the same folder as the running script, but the code tried to get it from some obscure Atom folder. How can I load a file from the same directory as my scripts?


Node.js supports __dirname and __filename global constants:


Thanks! Is there a better place to do a search for simple questions like this about coffeescripting in atom? I’m just asking because of the answer to this question. Do you think many of my future questions about coffeescripting in atom would be related to node rather than atom?


Yes, many of my early questions were things like, “How do I do X?” The majority of my questions were answered by one of three references:



I already have the first link bookmarked. :wink: Time to add a couple more!