pathogen

sane path utilities for node.js

Pathogen

Pathogen is an object oriented path utility library for node.js and browsers.

var pathogen = require('pathogen');
 
// objects 
var path = new pathogen('some/file.txt');
path.dirname().toString(); // './some/' 
path.resolve().toString(); // '/process/cwd/some/file.txt' 
path.resolve('/other/folder').toString(); // '/other/folder/some/file.txt' 
path.toWindows().toString(); // '.\\some\\file.txt' 
path.relative('some/otherfile.txt').toString(); // './otherfile.txt' 
path.basename(); // 'file.txt' 
 
// shortcuts 
pathogen.dirname('some/file.txt'); // './some/' 
pathogen.extname('some/file.txt'); // '.txt' 
pathogen.nix('\\windows\\system32\\'); // '/windows/system32/' 
pathogen.win('c:\\windows\\system32\\'); // 'c:\\windows\\system32\\' 
pathogen.sys('./some/path/'); // unix: './some/path/' windows: '.\\some\\path\\' 
pathogen.cwd() // unix: '/process/cwd/some/path/' windows: 'c:\\process\\cwd\\some\\path\\'