mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-25 16:07:37 +00:00
add primaries to _test
This commit is contained in:
parent
922f1d7639
commit
faaffca2a7
22
shell.js
22
shell.js
@ -530,8 +530,13 @@ function _test(options, path) {
|
||||
|
||||
// hack - only works with unary primaries
|
||||
options = parseOptions(options, {
|
||||
'b': 'block',
|
||||
'c': 'character',
|
||||
'd': 'directory',
|
||||
'f': 'file'
|
||||
'f': 'file',
|
||||
'L': 'link',
|
||||
'p': 'pipe',
|
||||
'S': 'socket'
|
||||
});
|
||||
|
||||
var canInterpret = false;
|
||||
@ -549,11 +554,26 @@ function _test(options, path) {
|
||||
|
||||
stats = fs.lstatSync(path);
|
||||
|
||||
if (options.block)
|
||||
return stats.isBlockDevice();
|
||||
|
||||
if (options.character)
|
||||
return stats.isCharacterDevice();
|
||||
|
||||
if (options.directory)
|
||||
return stats.isDirectory();
|
||||
|
||||
if (options.file)
|
||||
return stats.isFile();
|
||||
|
||||
if (options.link)
|
||||
return stats.isSymbolicLink();
|
||||
|
||||
if (options.pipe)
|
||||
return stats.isFIFO();
|
||||
|
||||
if (options.socket)
|
||||
return stats.isSocket()
|
||||
}; // test
|
||||
exports.test = wrap('test', _test);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user