path: add path.sep to get the path separator.

pull/24503/head
Yi, EungJun 2012-04-03 01:31:21 +09:00 committed by Ben Noordhuis
parent 6ba3e68bd2
commit 4bd54dad33
3 changed files with 26 additions and 0 deletions

View File

@ -138,3 +138,19 @@ an empty string. Examples:
path.extname('index')
// returns
''
## path.sep
The platform-specific file separator. `'\\'` or `'/'`.
An example on linux:
'foo/bar/baz'.split(path.sep)
// returns
['foo', 'bar', 'baz']
An example on windows:
'foo\\bar\\baz'.split(path.sep)
// returns
['foo', 'bar', 'baz']

View File

@ -258,6 +258,7 @@ if (isWindows) {
return outputParts.join('\\');
};
exports.sep = '\\';
} else /* posix */ {
@ -373,6 +374,7 @@ if (isWindows) {
return outputParts.join('/');
};
exports.sep = '/';
}

View File

@ -273,3 +273,11 @@ relativeTests.forEach(function(test) {
});
assert.equal(failures.length, 0, failures.join(''));
// path.sep tests
if (isWindows) {
// windows
assert.equal(path.sep, '\\');
} else {
// posix
assert.equal(path.sep, '/');
}