-
-
Save kostasxyz/e1200ff06b389f415a2ef50e72e9de24 to your computer and use it in GitHub Desktop.
Create a file within String using Gulp
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
| 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