Skip to content

Commit

Permalink
Merge pull request #56 from lge88/master
Browse files Browse the repository at this point in the history
test('-L', badlink) should return true
  • Loading branch information
arturadib committed Apr 6, 2013
2 parents f7d2e3c + 38f1d6d commit 3b57b24
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/resources/badlink
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 3b57b24

Please sign in to comment.