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


#1

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?


#2

Node.js supports __dirname and __filename global constants:

https://nodejs.org/api/globals.html#globals_filename


#3

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?


#4

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:

  1. http://coffeescript.org/
  2. https://nodejs.org/api/
  3. http://atom.io/docs/api/

#5

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