index.js
function(callback) {
		// TODO: don't wait until the end. Instead, emit immediately upon finding the template

		if (!templateFile) throw new Error('template not found in stream');

		templateFile.data = templateFile.data || {};

		files.forEach(function(file) {
			var newFile = templateFile.clone();

			newFile.data.file = file;
			newFile.path = file.path;

			this.push(newFile);
		}, this);

		callback();
	}
function(callback) {
		// TODO: don't wait until the end. Instead, emit immediately upon finding the template

		if (!templateFile) throw new Error('template not found in stream');

		templateFile.data = templateFile.data || {};

		files.forEach(function(file) {
			var newFile = templateFile.clone();

			newFile.data.file = file;
			newFile.path = file.path;

			this.push(newFile);
		}, this);

		callback();
	}
function ( callback ) { // TODO: don't wait until the end. Instead, emit immediately upon finding the template if ( ! templateFile ) throw new Error ( 'template not found in stream' ) ; templateFile . data = templateFile . data || { } ; files . forEach ( function ( file ) { var newFile = templateFile . clone ( ) ; newFile . data . file = file ; newFile . path = file . path ; this . push ( newFile ) ; } , this ) ; callback ( ) ; }
Wait until all files have come through, then attach the non-template files
Wait until all files have come through then attach the non - template files