From 89acc5c17e115ec03ec6b17341c3ffdf5e2db837 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Mon, 24 Jul 2017 19:16:35 +0100 Subject: [PATCH] Docs: Improve ES2015 task exporting examples (#1999) --- README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7f9996807..3bc84dbaf 100644 --- a/README.md +++ b/README.md @@ -149,13 +149,12 @@ const paths = { }; /* - * For small tasks you can use arrow functions and export + * For small tasks you can export arrow functions */ -const clean = () => del([ 'assets' ]); -export { clean }; +export const clean = () => del([ 'assets' ]); /* - * You can still declare named functions and export them as tasks + * You can also declare named functions and export them as tasks */ export function styles() { return gulp.src(paths.styles.src) @@ -177,13 +176,21 @@ export function scripts() { .pipe(gulp.dest(paths.scripts.dest)); } -export function watch() { + /* + * You could even use `export as` to rename exported tasks + */ +function watchFiles() { gulp.watch(paths.scripts.src, scripts); gulp.watch(paths.styles.src, styles); } +export { watchFiles as watch }; -const build = gulp.series(clean, gulp.parallel(styles, scripts)); -export { build }; +/* + * You can still use `gulp.task` + * for example to set task names that would otherwise be invalid + */ +const clean = gulp.series(clean, gulp.parallel(styles, scripts)); +gulp.task('clean', clean); /* * Export a default task