File tree Expand file tree Collapse file tree 4 files changed +57
-12
lines changed
Expand file tree Collapse file tree 4 files changed +57
-12
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,36 @@ var taskTree = require('../taskTree');
99
1010function logTasks ( env , localGulp ) {
1111 var tree = taskTree ( localGulp . tasks ) ;
12+ var padding = 0 ;
1213 tree . label = 'Tasks for ' + chalk . magenta ( tildify ( env . configPath ) ) ;
1314 archy ( tree )
1415 . split ( '\n' )
15- . forEach ( function ( v ) {
16- if ( v . trim ( ) . length === 0 ) {
17- return ;
16+ . filter ( function ( v , i ) {
17+ // Log first line as is
18+ if ( i === 0 ) {
19+ gutil . log ( v ) ;
20+ return false ;
21+ }
22+ // Search for longest line
23+ if ( v . length > padding ) {
24+ padding = v . length ;
25+ }
26+ return v . trim ( ) . length !== 0 ;
27+ } ) . forEach ( function ( v ) {
28+ var line = v . split ( ' ' ) ;
29+ var task = line . slice ( 1 ) . join ( ' ' ) ;
30+
31+ if ( / .└ / . test ( v ) ) {
32+ // Log dependencies as is
33+ gutil . log ( v ) ;
34+ } else {
35+ // Pretty task with optionnal description
36+ gutil . log (
37+ line [ 0 ] + ' ' + chalk . cyan ( task ) +
38+ Array ( padding + 3 - v . length ) . join ( ' ' ) +
39+ ( localGulp . tasks [ task ] . fn . description || '' )
40+ ) ;
1841 }
19- gutil . log ( v ) ;
2042 } ) ;
2143}
2244
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ function execute(opts, env) {
3030 label : 'Tasks for ' + chalk . magenta ( tildify ( env . configPath ) ) ,
3131 nodes : gulpInst . tree ( { deep : true } ) ,
3232 } ;
33- return logTasks ( tree ) ;
33+ return logTasks ( tree , gulpInst ) ;
3434 }
3535 if ( opts . tasksJson ) {
3636 return console . log (
Original file line number Diff line number Diff line change 11'use strict' ;
22
33var archy = require ( 'archy' ) ;
4+ var chalk = require ( 'chalk' ) ;
45var gutil = require ( 'gulp-util' ) ;
56
6- function logTasks ( tree ) {
7+ function logTasks ( tree , tasks ) {
8+ var padding = 0 ;
79 archy ( tree )
810 . split ( '\n' )
9- . filter ( function ( v ) {
10- return v . trim ( ) . length > 0 ;
11- } )
12- . forEach ( function ( v ) {
13- gutil . log ( v ) ;
11+ . filter ( function ( v , i ) {
12+ // Log first line as is
13+ if ( i === 0 ) {
14+ gutil . log ( v ) ;
15+ return false ;
16+ }
17+ // Search for longest line
18+ if ( v . length > padding ) {
19+ padding = v . length ;
20+ }
21+ return v . trim ( ) . length !== 0 ;
22+ } ) . forEach ( function ( v ) {
23+ var line = v . split ( ' ' ) ;
24+ var task = line . slice ( 1 ) . join ( ' ' ) ;
25+
26+ if ( / .└ / . test ( v ) ) {
27+ // Log dependencies as is
28+ gutil . log ( v ) ;
29+ } else {
30+ // Pretty task with optionnal description
31+ gutil . log (
32+ line [ 0 ] + ' ' + chalk . cyan ( task ) +
33+ Array ( padding + 3 - v . length ) . join ( ' ' ) +
34+ ( tasks . get ( task ) . description || '' )
35+ ) ;
36+ }
1437 } ) ;
1538}
1639
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ lab.experiment('flag: --tasks', function() {
1515 code . expect ( stdout [ 1 ] ) . to . contain ( '├── test1' ) ;
1616 code . expect ( stdout [ 2 ] ) . to . contain ( '├─┬ test2' ) ;
1717 code . expect ( stdout [ 3 ] ) . to . contain ( '│ └── test1' ) ;
18- code . expect ( stdout [ 4 ] ) . to . contain ( '├── test3' ) ;
18+ code . expect ( stdout [ 4 ] ) . to . contain ( '├── test3 description ' ) ;
1919 code . expect ( stdout [ 5 ] ) . to . contain ( '└─┬ default' ) ;
2020 code . expect ( stdout [ 6 ] ) . to . contain ( ' ├── test1' ) ;
2121 code . expect ( stdout [ 7 ] ) . to . contain ( ' └── test3' ) ;
You can’t perform that action at this time.
0 commit comments