• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

OverZealous/gulp-task-listing: Provides an easy way to get a listing of your tas ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

OverZealous/gulp-task-listing

开源软件地址(OpenSource Url):

https://github.com/OverZealous/gulp-task-listing

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

gulp-task-listing

NPM version Build Status

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.

Usage

Install using:

npm i --save-dev gulp-task-listing

Then add it to your gulpfile like so:

var gulp = require('gulp');
var taskListing = require('gulp-task-listing');

// Add a task to render the output
gulp.task('help', taskListing);

// Add some top-level and sub tasks
gulp.task('build', ['build-js', 'build-css']);
gulp.task('build-js', function() { ... })
gulp.task('build-css', function() { ... })

gulp.task('compile', ['compile-js', 'compile-css']);
gulp.task('compile-js', function() { ... })
gulp.task('compile-css', function() { ... })

Now run gulp help, and you'll see this:

Main Tasks
------------------------------
    build
    compile
    help

Sub Tasks
------------------------------
    build-css
    build-js
    compile-css
    compile-js

Customization

You can customize the output of the task listing by using the taskListing.withFilters(subtaskFilter, excludeFilter) method. Both arguments are optional. You can pass in a string, RegExp, or a custom function.

subtaskFilter

Providing this allows you to choose which tasks are Main Tasks (by returning false), and which are Sub Tasks (by returning true).

By default, this is defined as the regular expression /[-_:]/, which means that any task with a hyphen, underscore, or colon in it's name is assumed to be a subtask.

If, for example, you wanted to only use colons to determine a task's status, you could set it up like so:

gulp.task('help', taskListing.withFilters(/:/));

If you had something more complex, you can use a function, like so:

gulp.task('help', taskListing.withFilters(function(task) {
	isSubTask = // test task name for sub task properties
	return isSubTask;
}));

excludeFilter

The exclude filter allows you to remove tasks from the listing. If you want to remove tasks that contain the word secret, you could set it up like so:

gulp.task('help', taskListing.withFilters(null, 'secret'));

If you had something more complex, you can use a function, like so:

gulp.task('help', taskListing.withFilters(null, function(task) {
	exclude = // test task name for exclusion
	return exclude;
}));

Note: setting the first argument to null allows you to retain the default behavior for subtask detection.

License

MIT License




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap