According to the docs, node.js’s path.resolve function converts the passed argument to an absolute path. However, when I pass it the non-existent file '', it returns the current working directory:
~$ node -v
v0.8.14
~$ node
> require('path').resolve('')
'/Users/perimosocordiae'
> require('fs').statSync('')
Error: ENOENT, no such file or directory ''
Is this intended behavior? Are there any other cases in which a “resolved” path will exist when the input path doesn’t, or vice versa?
Other parts of the documentation say:
and
path.resolvecan be thought of, as the docs, say, as a series ofcdcommands–e.g., what would happen if I started atfrom(orprocess.cwd()if nofromis specified, as in your example) and manipulated that path with the string into.