зеркало из https://github.com/microsoft/shelljs.git
If a symbolic link is broken, test('-L', badlink) should still return true.
While test('-L', 404) should return false.
This commit is contained in:
Родитель
1604a3933d
Коммит
38f1d6d9c4
11
shell.js
11
shell.js
|
@ -584,15 +584,20 @@ function _test(options, path) {
|
|||
if (!canInterpret)
|
||||
error('could not interpret expression');
|
||||
|
||||
if (options.link) {
|
||||
try {
|
||||
return fs.lstatSync(path).isSymbolicLink();
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs.existsSync(path))
|
||||
return false;
|
||||
|
||||
if (options.exists)
|
||||
return true;
|
||||
|
||||
if (options.link)
|
||||
return fs.lstatSync(path).isSymbolicLink();
|
||||
|
||||
var stats = fs.statSync(path);
|
||||
|
||||
if (options.block)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
not_existed_file
|
|
@ -80,4 +80,12 @@ var result = shell.test('-L', 'resources/link');
|
|||
assert.equal(shell.error(), null);
|
||||
assert.equal(result, true);//true
|
||||
|
||||
var result = shell.test('-L', 'resources/badlink');
|
||||
assert.equal(shell.error(), null);
|
||||
assert.equal(result, true);//true
|
||||
|
||||
var result = shell.test('-L', 'resources/404');
|
||||
assert.equal(shell.error(), null);
|
||||
assert.equal(result, false);//false
|
||||
|
||||
shell.exit(123);
|
||||
|
|
Загрузка…
Ссылка в новой задаче