-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removed `getStats` function. * Added a `resolveSymlinks` function that exposes a `stat` property on file object as a side effect (making `getStats` obsolete). * Added tests. * Fixes #39.
- Loading branch information
1 parent
9b0d556
commit a8ac578
Showing
6 changed files
with
63 additions
and
22 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
var through2 = require('through2'); | ||
var fs = require('graceful-fs'); | ||
var path = require('path'); | ||
|
||
function resolveSymlinks() { | ||
return through2.obj(resolveFile); | ||
} | ||
|
||
// a stat property is exposed on file objects as a (wanted) side effect | ||
function resolveFile(globFile, enc, cb) { | ||
fs.lstat(globFile.path, function (err, stat) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
|
||
globFile.stat = stat; | ||
|
||
if (!stat.isSymbolicLink()) { | ||
return cb(null, globFile); | ||
} | ||
|
||
fs.realpath(globFile.path, function (err, filePath) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
|
||
globFile.base = path.dirname(filePath); | ||
globFile.path = filePath; | ||
|
||
// recurse to get real file stat | ||
resolveFile(globFile, enc, cb); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = resolveSymlinks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test.coffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters