@@ -58,10 +58,37 @@ declare namespace OxideV3And4 {
58
58
}
59
59
}
60
60
61
+ // This covers the Oxide API from v4.1.0+
62
+ declare namespace OxideV5 {
63
+ interface GlobEntry {
64
+ base : string
65
+ pattern : string
66
+ }
67
+
68
+ interface SourceEntry {
69
+ base : string
70
+ pattern : string
71
+ negated : boolean
72
+ }
73
+
74
+ interface ScannerOptions {
75
+ sources : Array < SourceEntry >
76
+ }
77
+
78
+ interface ScannerConstructor {
79
+ new ( options : ScannerOptions ) : Scanner
80
+ }
81
+
82
+ interface Scanner {
83
+ get files ( ) : Array < string >
84
+ get globs ( ) : Array < GlobEntry >
85
+ }
86
+ }
87
+
61
88
interface Oxide {
62
89
scanDir ?( options : OxideV1 . ScanOptions ) : OxideV1 . ScanResult
63
90
scanDir ?( options : OxideV2 . ScanOptions ) : OxideV2 . ScanResult
64
- Scanner ?: OxideV3And4 . ScannerConstructor
91
+ Scanner ?: OxideV3And4 . ScannerConstructor | OxideV5 . ScannerConstructor
65
92
}
66
93
67
94
async function loadOxideAtPath ( id : string ) : Promise < Oxide | null > {
@@ -150,7 +177,7 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
150
177
}
151
178
152
179
// V4
153
- else {
180
+ else if ( lte ( options . oxideVersion , '4.0.9999' ) ) {
154
181
let scanner = new ( oxide . Scanner as OxideV3And4 . ScannerConstructor ) ( {
155
182
sources : [
156
183
{ base : options . basePath , pattern : '**/*' } ,
@@ -163,4 +190,19 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
163
190
globs : scanner . globs . map ( ( g ) => ( { base : g . base , pattern : g . pattern } ) ) ,
164
191
}
165
192
}
193
+
194
+ // V5
195
+ else {
196
+ let scanner = new ( oxide . Scanner as OxideV5 . ScannerConstructor ) ( {
197
+ sources : [
198
+ { base : options . basePath , pattern : '**/*' , negated : false } ,
199
+ ...options . sources . map ( ( g ) => ( { base : g . base , pattern : g . pattern , negated : g . negated } ) ) ,
200
+ ] ,
201
+ } )
202
+
203
+ return {
204
+ files : scanner . files ,
205
+ globs : scanner . globs . map ( ( g ) => ( { base : g . base , pattern : g . pattern } ) ) ,
206
+ }
207
+ }
166
208
}
0 commit comments