-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Force gulp.src to fix order of files #687
Comments
You can use a plugin like https://github.com/sirlantis/gulp-order to order the file. But depending on file order is usually an anti-pattern anyways. |
I have just updated gulp the latest version (5 minutes ago) and files order definitely changed. This simple task just creates random code instead of filename-ordered concatenated code.
Really.. this happens right after I ran UpdateI had to revert gulp back to (older) version |
@yairEO Minimal example which reproduces the issue would be helpful. |
you are absolutely right. I will produce a test now (but this should be automatically tested by a test suit..) |
Here, a test project that shows the bug: |
I get the expected (a, b, c) order on osx 10.10.1. ps. You should remove node_modules & put it to .gitignore. Add package.json instead. |
yes you are right i should have put just |
I'm seeing the wrong order (c, a, b) on VirtualBox windows 7. It started happening with gulp 3.7.0.
I have no clue why but downgrading --edit Narrowed down to this commit: isaacs/node-graceful-fs@08471b2 |
this is a major major bug..someone should re-open this issue. I absolutely love Gulp and am using it in all my projects and this caused quite a mess |
It looks like I guess it's up to @contra to decide if and where this should be handled. |
I have a test & fix here: https://github.com/heikki/glob-stream/compare/master...fix-order
I think the original cause is that |
@heikki That fix will mess up the speed of gulp. One of the great things is that glob matches get emitted immediately, not after the whole fs has been traversed. Has anyone opened an issue on graceful-fs that they broke something here? |
I haven't opened any issues yet. Maybe the right place to fix this would be in |
@heikki Yeah it should go on glob if they introduced a regression without realizing it |
Opened issue in node-glob. ^ |
Works now. |
Closing, an |
@contra |
@mbcooper Run |
FYI, fix has been reverted in node-glob. isaacs/node-glob#143 (comment) |
Hm, what now? Should we leave this as is & add docs or do something in glob-stream if sort-option is specified? |
What about a config option that globs all before beginning to emit? |
Sync mode results are sorted by default so this ugly tweak probably works: if (opt.sync) {
globber.found.forEach(function(filename) {
stream.write({
cwd: opt.cwd,
base: basePath,
path: path.resolve(opt.cwd, filename)
});
});
stream.end();
} else {
globber.on('error', stream.emit.bind(stream, 'error'));
globber.on('end', function(/* some args here so can't use bind directly */){
stream.end();
});
globber.on('match', function(filename) {
stream.write({
cwd: opt.cwd,
base: basePath,
path: path.resolve(opt.cwd, filename)
});
});
} |
I think the cleaner way to do this is to let people specify a sort option, and if given it will tell glob-stream to pipe itself through a stream sorter |
I like async ordering to belonging in userland. Why build it in core? |
@phated What plugin do you use? |
@contra I don't use one, but https://github.com/sirlantis/gulp-order doesn't look bad. I think it should be updated to through2, but no other gripes really. |
@phated Doesn't seem to support the features needed to solve this specific ordering problem (alphabetical) |
@contra it can be adapted. I think userland should have a gulp-reorder that accepts a sort function. |
@contra https://www.npmjs.com/package/sort-stream2 should work with a custom sort function |
Depending on the use case use either gulp-sort (alphabetical etc.) or gulp-order (globs) |
I'd just interject that non-deterministic ordering causes unnecessary conflicts when managing a deploy via Git. It's cool, yet painful. |
Why not let the user decide via flag if gulp.src should return reliably ordered results (slower) or random results (faster)? |
totally agree with @musterknabe. |
@musterknabe +1 |
If i just pass mainBowerFiles result, which ordered based on dependencies for each module, into gulp's stream, then all files will be reordered and it broke app for example for
inject
orconcat
.For example, mainBowerFiles returns:
after
gulp-inject
we'll get:Since ur-router, angular-sanitize and angular-animate depends of angular, application crashes.
Can this be solved?
The text was updated successfully, but these errors were encountered: