Created
February 3, 2014 22:57
-
-
Save davewasmer/8794151 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # ... | |
| module.exports = -> | |
| output = new stream.Transform(objectMode: true) | |
| output._transform = (file, enc, callback) -> | |
| # Pass this file along (do this *before* finding dependencies to preserve load order) | |
| output.push(file) | |
| # Find include statements | |
| includes = file.contents.match(includeStatementPattern) | |
| for statement in includes | |
| includedFiles = resolveIncludedFilepaths(statement, file) | |
| for f in includedFiles | |
| # Take an included file, write back into this same stream to recursively check | |
| # for includes. | |
| output.write(f) | |
| return output |
This file contains hidden or 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
| findDependencies = require('find-dependencies') | |
| gulp.task 'scripts', -> | |
| gulp.src([ 'app/index.coffee' ]) | |
| .pipe(findDependencies()) | |
| .pipe(coffee()) | |
| # ... |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is that the gulp.src call can finish and emit an end event before the recursion from
findDependenciesfinishes, resulting in aError: write after endexception.In principle, I'm trying to take a single file, and mid-pipeline, expand that to more files, and emit those down the stream (from that mid-pipeline point on) in certain order.