Created
February 1, 2016 05:03
-
-
Save leocaseiro/528b526b2579a651dce6 to your computer and use it in GitHub Desktop.
Create a file within String using Gulp
This file contains 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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alright thanks man!