Node, as you all know has a require function. When you call this function with a relative path. The relative path is based on the location of your call. How is this done?
I want to make a function that reads a file, which also has the same behavior. That when I pass it a relative path, the path is determined based on the location of the call.
So, basically what I'm looking for is for a call as readFile("./my_file.txt") to be interpreted as readFile(__dirname + "/my_file.txt").
I could of-course just always add __dirname, but I'm trying to eliminate that, and I'm curious how require does it.