File tree Expand file tree Collapse file tree 3 files changed +40
-12
lines changed
Expand file tree Collapse file tree 3 files changed +40
-12
lines changed Original file line number Diff line number Diff line change @@ -136,14 +136,38 @@ function handleArguments(env) {
136136
137137function logTasks ( env , localGulp ) {
138138 var tree = taskTree ( localGulp . tasks ) ;
139+ var padding = 0 ;
139140 tree . label = 'Tasks for ' + chalk . magenta ( tildify ( env . configPath ) ) ;
140141 archy ( tree )
141142 . split ( '\n' )
142- . forEach ( function ( v ) {
143- if ( v . trim ( ) . length === 0 ) {
144- return ;
143+ . filter ( function ( v , i ) {
144+ // log first line as is
145+ if ( i === 0 ) {
146+ gutil . log ( v ) ;
147+ return false ;
148+ }
149+ // search for longest line
150+ if ( v . length > padding ) {
151+ padding = v . length ;
152+ }
153+ return v . trim ( ) . length !== 0 ;
154+
155+ } ) . forEach ( function ( v ) {
156+ var line = v . split ( ' ' ) ;
157+ var task = line . slice ( 1 ) . join ( ' ' ) ;
158+
159+ if ( / .└ / . test ( v ) ) {
160+ // log dependencies as is
161+ gutil . log ( v ) ;
162+ } else {
163+ // pretty task with optionnal description
164+ gutil . log (
165+ line [ 0 ] + ' ' +
166+ chalk . cyan ( task ) +
167+ Array ( padding + 3 - v . length ) . join ( ' ' ) +
168+ ( localGulp . tasks [ task ] . fn . description || '' )
169+ ) ;
145170 }
146- gutil . log ( v ) ;
147171 } ) ;
148172}
149173
Original file line number Diff line number Diff line change @@ -9,12 +9,14 @@ lab.experiment('flag: --tasks', function () {
99
1010 lab . test ( 'prints the task list' , function ( done ) {
1111 child . exec ( 'node ' + __dirname + '/../bin/gulp.js --tasks --cwd ./test' , function ( err , stdout ) {
12- stdout = stdout . replace ( / \\ / g, '/' ) ;
13- code . expect ( stdout ) . to . contain ( '/gulp-cli/test' ) ;
14- code . expect ( stdout ) . to . contain ( '├── test1' ) ;
15- code . expect ( stdout ) . to . contain ( '├── test2' ) ;
16- code . expect ( stdout ) . to . contain ( '├── test3' ) ;
17- code . expect ( stdout ) . to . contain ( '└── default' ) ;
12+ code . expect ( stdout ) . to . contain ( 'Tasks for' ) ;
13+ stdout = stdout . replace ( / \\ / g, '/' ) . split ( 'Tasks for' ) [ 1 ] . split ( '\n' ) ;
14+ code . expect ( stdout [ 0 ] ) . to . contain ( '/gulp-cli/test' ) ;
15+ code . expect ( stdout [ 1 ] ) . to . contain ( '├── test1' ) ;
16+ code . expect ( stdout [ 2 ] ) . to . contain ( '├─┬ test2' ) ;
17+ code . expect ( stdout [ 3 ] ) . to . contain ( '│ └── test1' ) ;
18+ code . expect ( stdout [ 4 ] ) . to . contain ( '├── test3 description' ) ;
19+ code . expect ( stdout [ 5 ] ) . to . contain ( '└── default' ) ;
1820 done ( err ) ;
1921 } ) ;
2022 } ) ;
Original file line number Diff line number Diff line change 33var gulp = require ( 'gulp' ) ;
44
55function noop ( ) { }
6+ function described ( ) { }
7+ described . description = 'description' ;
68
79gulp . task ( 'test1' , noop ) ;
8- gulp . task ( 'test2' , noop ) ;
9- gulp . task ( 'test3' , noop ) ;
10+ gulp . task ( 'test2' , [ 'test1' ] , noop ) ;
11+ gulp . task ( 'test3' , described ) ;
1012
1113gulp . task ( 'default' , noop ) ;
You can’t perform that action at this time.
0 commit comments