From e3080a442ff8d88e44c90ddd52ff16b827445fa7 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Thu, 24 Sep 2015 15:46:38 -0600 Subject: [PATCH 1/2] Definitions for gulp-task-listing --- gulp-task-listing/gulp-task-listing-tests.ts | 15 ++++++++ gulp-task-listing/gulp-task-listing.d.ts | 40 ++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 gulp-task-listing/gulp-task-listing-tests.ts create mode 100644 gulp-task-listing/gulp-task-listing.d.ts diff --git a/gulp-task-listing/gulp-task-listing-tests.ts b/gulp-task-listing/gulp-task-listing-tests.ts new file mode 100644 index 0000000000..7d2c293d39 --- /dev/null +++ b/gulp-task-listing/gulp-task-listing-tests.ts @@ -0,0 +1,15 @@ +/// +/// + +import gulp = require('gulp'); +import gulpTaskListing = require('gulp-task-listing'); + +gulp.task('help-default', gulpTaskListing); +gulp.task('help-subTaskRegexFilter', gulpTaskListing.withFilters(/\d+/)); +gulp.task('help-subTaskFunctionFilter', gulpTaskListing.withFilters(task => task.length > 3)); +gulp.task('help-excludeRegexFilter', gulpTaskListing.withFilters(null, /\w+/)); +gulp.task('help-excludeFunctionFilter', gulpTaskListing.withFilters(null, task => task.length < 2)); +gulp.task('help-bothFilters1', gulpTaskListing.withFilters(/\d+/, /\w+/)); +gulp.task('help-bothFilters2', gulpTaskListing.withFilters(/\d+/, task => task.length > 3)); +gulp.task('help-bothFilters3', gulpTaskListing.withFilters(task => task.length < 2, /\w+/)); +gulp.task('help-bothFilters4', gulpTaskListing.withFilters(task => task.length < 2, task => task.length > 3)); \ No newline at end of file diff --git a/gulp-task-listing/gulp-task-listing.d.ts b/gulp-task-listing/gulp-task-listing.d.ts new file mode 100644 index 0000000000..022a0118b9 --- /dev/null +++ b/gulp-task-listing/gulp-task-listing.d.ts @@ -0,0 +1,40 @@ +// Type definitions for gulp-task-listing +// Project: https://github.com/OverZealous/gulp-task-listing +// Definitions by: Joe Skeen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * Provides an easy way to get a listing of your tasks from your gulpfile. By default, the + * output groups tasks based on whether or not they contain a hyphen (-), underscore (_), + * or colon (:) in their name. + * + * You can optionally override the Regexp used to determine whether a task is a primary or + * subtask, as well as filter out tasks you don't want to see in the output. + */ +declare module 'gulp-task-listing' { + + /** + * Provides an easy way to get a listing of your tasks from your gulpfile. By default, the + * output groups tasks based on whether or not they contain a hyphen (-), underscore (_), + * or colon (:) in their name. + * + * You can optionally override the Regexp used to determine whether a task is a primary or + * subtask, as well as filter out tasks you don't want to see in the output. + */ + interface GulpTaskListing { + (cb): void; + /** + * Allows for custom filtering of Gulp tasks in the listing + * + * @param subTaskFilter a RegExp or Function returning whether the given task is a subtask + * @param excludeFilter a RegExp or Function returning whether the given task should be excluded from the listing + */ + withFilters(subTaskFilter: RegExp | FilterFunction, excludeFilter?: RegExp | FilterFunction): (cb) => void; + } + + type FilterFunction = (task: string) => boolean; + + var gulpTaskListing: GulpTaskListing; + + export = gulpTaskListing; +} From 8c215b7ee437b89593e230277eb861d0be1eb141 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Thu, 24 Sep 2015 15:53:19 -0600 Subject: [PATCH 2/2] Function type for callback --- gulp-task-listing/gulp-task-listing.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulp-task-listing/gulp-task-listing.d.ts b/gulp-task-listing/gulp-task-listing.d.ts index 022a0118b9..8409f4b801 100644 --- a/gulp-task-listing/gulp-task-listing.d.ts +++ b/gulp-task-listing/gulp-task-listing.d.ts @@ -22,14 +22,14 @@ declare module 'gulp-task-listing' { * subtask, as well as filter out tasks you don't want to see in the output. */ interface GulpTaskListing { - (cb): void; + (cb: Function): void; /** * Allows for custom filtering of Gulp tasks in the listing * * @param subTaskFilter a RegExp or Function returning whether the given task is a subtask * @param excludeFilter a RegExp or Function returning whether the given task should be excluded from the listing */ - withFilters(subTaskFilter: RegExp | FilterFunction, excludeFilter?: RegExp | FilterFunction): (cb) => void; + withFilters(subTaskFilter: RegExp | FilterFunction, excludeFilter?: RegExp | FilterFunction): (cb: Function) => void; } type FilterFunction = (task: string) => boolean;