File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ // usage: node expand-task.js <task name>
2
+ // must be run from root of the Node driver
3
+ //
4
+ // The output is pipeable: `node expand-task.js <task name> | jq '.'`
5
+
6
+ import { readFileSync } from 'fs' ;
7
+ import { load } from 'js-yaml' ;
8
+ import { gte } from 'semver' ;
9
+ import { Readable } from 'stream' ;
10
+ import { inspect } from 'util' ;
11
+
12
+ if ( ! gte ( process . version , '16.0.0' ) ) {
13
+ console . error ( 'expand-tasks.mjs requires Node16+' ) ;
14
+ process . exit ( 1 ) ;
15
+ }
16
+
17
+ const config = load ( readFileSync ( '.evergreen/config.yml' ) ) ;
18
+ const taskName = ( process . argv [ 2 ] ?? '' ) . trim ( ) ;
19
+
20
+ const task = config . tasks . find ( ( { name } ) => name === taskName ) ;
21
+
22
+ if ( ! task ) {
23
+ process . exit ( ) ;
24
+ }
25
+
26
+ const commands = task . commands . flatMap ( ( { func } ) => config . functions [ func ] ) ;
27
+
28
+ if ( process . stdout . isTTY ) {
29
+ console . log ( inspect ( commands , { depth : Infinity , colors : true } ) ) ;
30
+ } else {
31
+ Readable . from ( commands )
32
+ . map ( command => JSON . stringify ( command ) )
33
+ . pipe ( process . stdout ) ;
34
+ }
You can’t perform that action at this time.
0 commit comments