@@ -23,7 +23,46 @@ internals.toArray = (v) => {
23
23
} ;
24
24
25
25
26
- internals . scan = async ( travisYaml ) => {
26
+ internals . normalizeImports = ( travisYaml ) => {
27
+
28
+ return internals . toArray ( travisYaml . import ) . map ( ( entry ) => {
29
+
30
+ if ( typeof entry === 'string' ) {
31
+ entry = { source : entry } ;
32
+ }
33
+
34
+ return entry ;
35
+ } ) ;
36
+ } ;
37
+
38
+
39
+ internals . applyImports = async ( yaml , { loadFile } ) => {
40
+
41
+ if ( ! yaml . import ) {
42
+ return ;
43
+ }
44
+
45
+ const imports = internals . normalizeImports ( yaml ) ;
46
+
47
+ for ( const entry of imports ) {
48
+
49
+ const buffer = await loadFile ( entry . source ) ;
50
+
51
+ const imported = Yaml . safeLoad ( buffer , {
52
+ schema : Yaml . FAILSAFE_SCHEMA ,
53
+ json : true
54
+ } ) ;
55
+
56
+ for ( const key in imported ) {
57
+ yaml [ key ] = imported [ key ] ;
58
+ }
59
+ }
60
+ } ;
61
+
62
+
63
+ internals . scan = async ( travisYaml , options ) => {
64
+
65
+ await internals . applyImports ( travisYaml , options ) ;
27
66
28
67
const rawSet = new Set ( ) ;
29
68
@@ -35,7 +74,7 @@ internals.scan = async (travisYaml) => {
35
74
36
75
for ( const env of internals . toArray ( travisYaml . env . matrix ) ) {
37
76
38
- const matches = env . match ( / (?: N O D E J S _ V E R | T R A V I S _ N O D E _ V E R S I O N | N O D E _ V E R ) = " ? ( n o d e \/ ) ? (?< version > [ \w . / * ] + ) " ? / ) ; /* hack syntax highlighter 🤦♂️ */
77
+ const matches = env . match ( / (?: N O D E J S _ V E R | T R A V I S _ N O D E _ V E R S I O N | N O D E _ V E R ) = " ? ( n o d e \/ ) ? (?< version > [ \w . / * ] + ) " ? / ) ;
39
78
40
79
if ( matches ) {
41
80
rawSet . add ( matches . groups . version ) ;
@@ -96,6 +135,6 @@ exports.detect = async ({ loadFile }) => {
96
135
} ) ;
97
136
98
137
return {
99
- travis : await internals . scan ( travisYaml )
138
+ travis : await internals . scan ( travisYaml , { loadFile } )
100
139
} ;
101
140
} ;
0 commit comments