-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symlinked directories cause EISDIR error from vinyl-fs.src()
#39
Comments
Has this been looked into? I'm running into this same problem. |
👍 |
Maybe this is related:
https://github.com/isaacs/node-glob#comparisons-to-other-fnmatchglob-implementations --edit |
@heikki Any info on why "maybe not"? |
@contra On first read it seemed related and then I started to doubt because I'm not familiar with |
bump? |
I'm also running into this. Anyone figured out a workaround? |
We also reproduce this error in @SassDoc. There's no stack trace on this So it appears not to be a problem with node-glob; maybe this function should be returning true when the file is a symlink to a directory, or symlinks should be resolved to actual files while here? Fixed on my side with the following (rather dirty) patch: diff --git a/lib/src/index.js b/lib/src/index.js
index 01b5430..86f6ca7 100644
--- a/lib/src/index.js
+++ b/lib/src/index.js
@@ -6,6 +6,8 @@ var gs = require('glob-stream');
var File = require('vinyl');
var duplexify = require('duplexify');
var merge = require('merge-stream');
+var fs = require('graceful-fs');
+var path = require('path');
var filterSince = require('./filterSince');
var getContents = require('./getContents');
@@ -15,6 +17,27 @@ function createFile(globFile, enc, cb) {
cb(null, new File(globFile));
}
+function resolveSymlinks(globFile, enc, cb) {
+ fs.lstat(globFile.path, function (err, stat) {
+ if (err) return cb(err);
+
+ if (!stat.isSymbolicLink()) {
+ return cb(null, globFile);
+ }
+
+ fs.realpath(globFile.path, function (err, filePath) {
+ if (err) return cb(err);
+
+ cb(null, {
+ cwd: globFile.cwd,
+ base: path.dirname(filePath),
+ path: filePath
+ });
+ });
+ });
+}
+
function src(glob, opt) {
var options = assign({
read: true,
@@ -37,6 +60,7 @@ function src(glob, opt) {
var globStream = gs.create(glob, options);
var outputStream = globStream
+ .pipe(through.obj(resolveSymlinks))
.pipe(through.obj(createFile))
.pipe(getStats(options)); |
@valeriangalliat That runs a stat on each file twice (once in getStats, once in resolveSymlinks) |
Totally, hence me qualifying it as "rather dirty". :/ But maybe propagating the stats object in |
@valeriangalliat Yep, or make getStats resolve symlinks |
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
The fix for #38 is causing me issues when I have symlinked directories. In my use case I want to follow symlinks and copy their contents, etc. However the use of
lstat
causesvinyl-fs
to think symlinked directories are files and I think it tries to load their content resulting in EISDIR errors.I have created the following project to demonstrate the problem
https://github.com/pghalliday/test-vinyl-fs
The text was updated successfully, but these errors were encountered: