Merge pull request #5628 from tkqubo/gulp-help

Add gulp-help
This commit is contained in:
Masahiro Wakame
2015-09-03 02:15:16 +09:00
2 changed files with 166 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="../gulp/gulp.d.ts" />
/// <reference path="gulp-help.d.ts" />
'use strict';
import gulpHelp = require('gulp-help');
var gulp = gulpHelp(require('gulp'));
gulp.task('lint', 'Lints all server side js', function () {
var jshint: () => NodeJS.ReadWriteStream;
gulp.src('./lib/**/*.js')
.pipe(jshint());
});
gulp.task('task-hidden-from-help', false, function () {
// ...
});
gulp.task('version', 'prints the version.', [], function() {
// ...
}, {
aliases: ['v', 'V']
});
gulp.task('version', 'prints the version.', [], function () {
// ...
}, {
options: {
'env=prod': 'description of env, perhaps with available values',
'key=val': 'description of key & val',
'key': 'description of key'
}
});
var gulp2 = require('gulp');
gulpHelp(gulp2, {
description: 'Desc',
aliases: ['h'],
hideEmpty: true,
hideDepsMessage: false,
afterPrintCallback(): any {
console.log('done');
}
});
+119
View File
@@ -0,0 +1,119 @@
// Type definitions for gulp-help
// Project: https://github.com/chmontgomery/gulp-help
// Definitions by: Qubo <https://github.com/tkQubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../bluebird/bluebird.d.ts" />
/// <reference path="../node/node.d.ts" />
/// <reference path="../gulp/gulp.d.ts" />
/// <reference path="../orchestrator/orchestrator.d.ts" />
declare module "gulp-help" {
import Orchestrator = require('orchestrator');
import gulp = require('gulp');
type HelpOption = string|boolean;
namespace gulpHelp {
interface TaskMethod {
/**
* Define a task.
*
* @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them.
* @param help Custom help message as a string. If you want to hide the task from the help menu, supply false
* @param deps an array of tasks to be executed and completed before your task will run.
* @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()).
* @param option task options
*/
(name: string, help: HelpOption, deps: string[], fn?: gulp.TaskCallback, option?: TaskOptions): any;
/**
* Define a task.
*
* @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them.
* @param help Custom help message as a string. If you want to hide the task from the help menu, supply false
* @param deps an array of tasks to be executed and completed before your task will run.
*/
(name: string, help: HelpOption, deps: string[]): any;
/**
* Define a task.
*
* @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them.
* @param help Custom help message as a string. If you want to hide the task from the help menu, supply false
* @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()).
* @param option task options
*/
(name: string, help: HelpOption, fn?: gulp.TaskCallback, option?: TaskOptions): any;
/**
* Define a task.
*
* @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them.
* @param help Custom help message as a string. If you want to hide the task from the help menu, supply false
*/
(name: string, help: HelpOption): any;
/**
* Define a task.
*
* @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them.
* @param deps an array of tasks to be executed and completed before your task will run.
* @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()).
* @param option task options
*/
(name: string, deps: string[], fn?: gulp.TaskCallback, option?: TaskOptions): any;
/**
* Define a task.
*
* @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them.
* @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()).
* @param option task options
*/
(name: string, fn?: gulp.TaskCallback, option?: TaskOptions): any;
}
interface GulpHelp extends Orchestrator {
task: TaskMethod;
src: gulp.SrcMethod;
dest: gulp.DestMethod;
watch: gulp.WatchMethod;
}
interface TaskOptions {
/**
* List of aliases for this task
*/
aliases?: string[];
/**
* Object documenting options which can be passed to your task
*/
options?: { [key: string]: string };
}
interface GulpHelpOptions {
/**
* Modifies the default help message
*/
description?: string;
/**
* Adds aliases to the default help task
*/
aliases?: string[];
/**
* Hide all tasks with no help message defined. Useful when including 3rd party tasks
*/
hideEmpty?: boolean;
/**
* Hide all task dependencies
*/
hideDepsMessage?: boolean;
/**
* A function to run after the default help task runs
*/
afterPrintCallback?: Function;
}
}
function gulpHelp(gulp: gulp.Gulp, options?: gulpHelp.GulpHelpOptions): gulpHelp.GulpHelp;
export = gulpHelp;
}