mirror of
https://github.com/bower/bower.git
synced 2026-01-13 16:28:05 -05:00
Sometimes it return ENOENT instead of ENODIR for normal files. This broke code paths in few places. Also, see: https://github.com/isaacs/chmodr/pull/8
25 lines
507 B
JavaScript
25 lines
507 B
JavaScript
var Q = require('q');
|
|
var fs = require('./fs');
|
|
|
|
function validLink(file) {
|
|
// Ensures that a file is a symlink that points
|
|
// to a valid file
|
|
return Q.nfcall(fs.lstat, file)
|
|
.then(function (lstat) {
|
|
if (!lstat.isSymbolicLink()) {
|
|
return [false];
|
|
}
|
|
|
|
return Q.nfcall(fs.stat, file)
|
|
.then(function (stat) {
|
|
return [stat];
|
|
});
|
|
})
|
|
.fail(function (err) {
|
|
return [false, err];
|
|
});
|
|
}
|
|
|
|
module.exports = validLink;
|
|
|