javascript - How to locate parent path node.js OS independent manner -


i want portable across oss

var path = require("path"),     fs = require("fs");  fs.readfile(path.join(__dirname, '../..', 'foo.bar')); 

this code works mac/linux/unix;

what universal manner write code?

the correct , easiest way be:

path.join(__dirname, '..', '..', 'foo.bar'); 

but if want write separator manually, this:

path.join(__dirname, '..' + path.sep + '..', 'foo.bar'); 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -