Files
bower/lib/util/validLink.js
Adam Stankiewicz df8e5a16be Fix readdir call on Windows
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
2015-10-14 16:09:38 +02:00

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;