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
Post a Comment