Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Joouis/gulp-tasklist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-tasklist

Get task list of gulp file in node.js.

Why

We all know that gulp --tasks or gulp -T can list all tasks of the gulpfile, but they consume too much time than I thought. Otherwise, I want to get the list in my node program, that means I have to wait, catch, process raw data from stdout. It's still another way to get the list in node, but … not elegant!

So I write a simple parser with esprima to achieve this goal, and found it is really faster than previous ways.

Installation

npm install --save gulp-tasklist

How to use

Here is the official demo code on Gulp website:

var gulp = require('gulp');
var pug = require('gulp-pug');
var less = require('gulp-less');
var minifyCSS = require('gulp-csso');

gulp.task('html', function(){
  return gulp.src('client/templates/*.pug')
    .pipe(pug())
    .pipe(gulp.dest('build/html'))
});

gulp.task('css', function(){
  return gulp.src('client/templates/*.less')
    .pipe(less())
    .pipe(minifyCSS())
    .pipe(gulp.dest('build/css'))
});

gulp.task('default', [ 'html', 'css' ]);

Just require gulp-tasklist package and call getList() method:

const TaskList = require('gulp-tasklist');
const path = require('path');

let filePath = path.join(__dirname, 'gulpfile.js');
// Just pass the gulpfile path and get the list object
let res = TaskList.getList(filePath);

if (res.err) throw res.err;
else console.log(res.data);

// As result stdout prints:
// { html: { deps: [] },
//   css: { deps: [] },
//   default: { deps: [ 'html', 'css' ] } }

License

MIT

About

Get tasks list of gulp file in node.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published