'use strict';

/**
 * Recipe:
 * copy files
 *
 * Ingredients:
 * gulp-flatten
 * gulp.src()
 * gulp.dest()
 *
 * @param gulp
 * @param config
 * @param stream
 * @param done
 * @returns stream
 */
function copyTask(gulp, config, stream, done) {
	var flatten = require('gulp-flatten');

	if (!stream) {
		stream = gulp.src(config.src.globs, config.src.options);
	}

	if (config.flatten) {
		stream = stream.pipe(flatten());
	}
	return stream.pipe(gulp.dest(config.dest.path, config.dest.options));
}

copyTask.schema = {
	"title": "copy",
	"description": "",
	"properties": {
		"src": {
			"description": ""
		},
		"dest": {
			"description": ""
		},
		"flatten": {
			"description": "",
			"type": "boolean",
		}
	},
	"required": ["src", "dest"]
};

copyTask.type = 'task';

module.exports = copyTask;

@@ -108,57 +108,8 @@
 %0A *%0A
- * @param gulp%0A * @param config%0A * @param stream%0A
  * @
@@ -164,30 +164,8 @@
 ask(
-gulp, config, stream, 
 done
@@ -214,33 +214,144 @@
 ;%0A%0A%09
-if (!stream) %7B%0A%09%09stream =
+var context = this,%0A%09    gulp = context.gulp,%0A%09%09config = context.config,%0A%09%09upstream = context.upstream,%0A%09%09stream;%0A%0A%09stream = upstream %7C%7C
  gul
@@ -399,12 +399,8 @@
 s);%0A
-%09%7D%0A%0A
 %09if 

rename upstream; fix recipe function signature