@@ -36,8 +36,8 @@ declare namespace OxideV2 {
36
36
}
37
37
}
38
38
39
- // This covers the Oxide API from v4.0.0-alpha.20 +
40
- declare namespace OxideV3 {
39
+ // This covers the Oxide API from v4.0.0-alpha.30 +
40
+ declare namespace OxideV3And4 {
41
41
interface GlobEntry {
42
42
base : string
43
43
pattern : string
@@ -61,7 +61,7 @@ declare namespace OxideV3 {
61
61
interface Oxide {
62
62
scanDir ?( options : OxideV1 . ScanOptions ) : OxideV1 . ScanResult
63
63
scanDir ?( options : OxideV2 . ScanOptions ) : OxideV2 . ScanResult
64
- Scanner ?: OxideV3 . ScannerConstructor
64
+ Scanner ?: OxideV3And4 . ScannerConstructor
65
65
}
66
66
67
67
async function loadOxideAtPath ( id : string ) : Promise < Oxide | null > {
@@ -78,11 +78,17 @@ interface GlobEntry {
78
78
pattern : string
79
79
}
80
80
81
+ interface SourceEntry {
82
+ base : string
83
+ pattern : string
84
+ negated : boolean
85
+ }
86
+
81
87
interface ScanOptions {
82
88
oxidePath : string
83
89
oxideVersion : string
84
90
basePath : string
85
- sources : Array < GlobEntry >
91
+ sources : Array < SourceEntry >
86
92
}
87
93
88
94
interface ScanResult {
@@ -118,38 +124,43 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
118
124
}
119
125
120
126
// V2
121
- if ( lte ( options . oxideVersion , '4.0.0-alpha.19' ) ) {
127
+ else if ( lte ( options . oxideVersion , '4.0.0-alpha.19' ) ) {
122
128
let result = oxide . scanDir ( {
123
129
base : options . basePath ,
124
- sources : options . sources ,
130
+ sources : options . sources . map ( ( g ) => ( { base : g . base , pattern : g . pattern } ) ) ,
125
131
} )
126
132
127
133
return {
128
134
files : result . files ,
129
- globs : result . globs ,
135
+ globs : result . globs . map ( ( g ) => ( { base : g . base , pattern : g . pattern } ) ) ,
130
136
}
131
137
}
132
138
133
139
// V3
134
- if ( lte ( options . oxideVersion , '4.0.0-alpha.30' ) ) {
135
- let scanner = new oxide . Scanner ( {
140
+ else if ( lte ( options . oxideVersion , '4.0.0-alpha.30' ) ) {
141
+ let scanner = new ( oxide . Scanner as OxideV3And4 . ScannerConstructor ) ( {
136
142
detectSources : { base : options . basePath } ,
137
- sources : options . sources ,
143
+ sources : options . sources . map ( ( g ) => ( { base : g . base , pattern : g . pattern } ) ) ,
138
144
} )
139
145
140
146
return {
141
147
files : scanner . files ,
142
- globs : scanner . globs ,
148
+ globs : scanner . globs . map ( ( g ) => ( { base : g . base , pattern : g . pattern } ) ) ,
143
149
}
144
150
}
145
151
146
152
// V4
147
- let scanner = new oxide . Scanner ( {
148
- sources : [ { base : options . basePath , pattern : '**/*' } , ...options . sources ] ,
149
- } )
153
+ else {
154
+ let scanner = new ( oxide . Scanner as OxideV3And4 . ScannerConstructor ) ( {
155
+ sources : [
156
+ { base : options . basePath , pattern : '**/*' } ,
157
+ ...options . sources . map ( ( g ) => ( { base : g . base , pattern : g . pattern } ) ) ,
158
+ ] ,
159
+ } )
150
160
151
- return {
152
- files : scanner . files ,
153
- globs : scanner . globs ,
161
+ return {
162
+ files : scanner . files ,
163
+ globs : scanner . globs . map ( ( g ) => ( { base : g . base , pattern : g . pattern } ) ) ,
164
+ }
154
165
}
155
166
}
0 commit comments