Reputation: 6313
Specific question
Can I run gulp from node and get a return var from it without manipulating any files, just reading from them?
More background
I am trying to build something not unlike Modernizr's build tool. I have several files on disk and want to give the visitor the chance to select a subset of those in a form and submit it.
What should happen then is the visitor will get a download as an return of the submission (a zip file) with those files he/she selected curated and processed (minifying, concatenation and some other magic).
Now in my craze I created a POC that is a NodeJS app, listening to a port and relies heavily on callbacks to go through each set of the magic to then build all files and zip them up in memory and return it as the result to the request.
That feels dirty though. I think it should all be streams neatly put together for plug and play action BUT I am not sure how. I have never used gulp and I am under the impression it would manipulate files only on disk?
The reason I want to create everything in memory is because I don't want to worry about a garbage collector and multiple sessions overwriting each other.
Upvotes: 0
Views: 691
Reputation: 29985
Can't you write gulp plugin and use it instead of gulp.dest() call? Gulp operate on streams/pipes so may be this will be a solution. I don't think getting result on disk is the only think Gulp can do.
Upvotes: 1
Reputation: 778
Gulp works on glob selections. As far as i know there is no existing way (in gulp) to pass specific files other then to hardcode them.
The only way i can concieve of to paramaterize file selection is to either:
a. Create your task so you can pass them in as flags in the CLI for this something like yargs would be useful
b. Set the base dir and create something that will automatically display the files, examining a plugin like inquirer should help
Upvotes: 1