Skip to content

Instantly share code, notes, and snippets.

@leocaseiro
Created February 1, 2016 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save leocaseiro/528b526b2579a651dce6 to your computer and use it in GitHub Desktop.
Save leocaseiro/528b526b2579a651dce6 to your computer and use it in GitHub Desktop.
Create a file within String using Gulp
gulp.task('createFile', function() {
var filename = 'app.js';
var string = "(function() {\n 'use strict';\n angular.module('App', ['ui-route']);\n})();";
return stringToFile(filename, string)
.pipe(gulp.dest('./js'));
});
function stringToFile(filename, string) {
var src = require('stream').Readable({ objectMode: true });
src._read = function () {
this.push(new $.util.File({ cwd: __dirname, base: '', path: filename, contents: new Buffer(string) }));
this.push(null);
};
return src
}
@warengonzaga
Copy link

alright thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment