@@ -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 > {
@@ -73,21 +73,22 @@ async function loadOxideAtPath(id: string): Promise<Oxide | null> {
73
73
return oxide
74
74
}
75
75
76
- interface GlobEntry {
76
+ interface SourceEntry {
77
77
base : string
78
78
pattern : string
79
+ negated : boolean
79
80
}
80
81
81
82
interface ScanOptions {
82
83
oxidePath : string
83
84
oxideVersion : string
84
85
basePath : string
85
- sources : Array < GlobEntry >
86
+ sources : Array < SourceEntry >
86
87
}
87
88
88
89
interface ScanResult {
89
90
files : Array < string >
90
- globs : Array < GlobEntry >
91
+ sources : Array < SourceEntry >
91
92
}
92
93
93
94
/**
@@ -113,43 +114,48 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
113
114
114
115
return {
115
116
files : result . files ,
116
- globs : result . globs . map ( ( g ) => ( { base : g . base , pattern : g . glob } ) ) ,
117
+ sources : result . globs . map ( ( s ) => ( { base : s . base , pattern : s . glob , negated : false } ) ) ,
117
118
}
118
119
}
119
120
120
121
// V2
121
- if ( lte ( options . oxideVersion , '4.0.0-alpha.19' ) ) {
122
+ else if ( lte ( options . oxideVersion , '4.0.0-alpha.19' ) ) {
122
123
let result = oxide . scanDir ( {
123
124
base : options . basePath ,
124
125
sources : options . sources ,
125
126
} )
126
127
127
128
return {
128
129
files : result . files ,
129
- globs : result . globs ,
130
+ sources : result . globs . map ( ( s ) => ( { base : s . base , pattern : s . pattern , negated : false } ) ) ,
130
131
}
131
132
}
132
133
133
134
// V3
134
- if ( lte ( options . oxideVersion , '4.0.0-alpha.30' ) ) {
135
- let scanner = new oxide . Scanner ( {
135
+ else if ( lte ( options . oxideVersion , '4.0.0-alpha.30' ) ) {
136
+ let scanner = new ( oxide . Scanner as OxideV3And4 . ScannerConstructor ) ( {
136
137
detectSources : { base : options . basePath } ,
137
- sources : options . sources ,
138
+ sources : options . sources . map ( ( s ) => ( { base : s . base , pattern : s . pattern } ) ) ,
138
139
} )
139
140
140
141
return {
141
142
files : scanner . files ,
142
- globs : scanner . globs ,
143
+ sources : scanner . globs . map ( ( s ) => ( { base : s . base , pattern : s . pattern , negated : false } ) ) ,
143
144
}
144
145
}
145
146
146
147
// V4
147
- let scanner = new oxide . Scanner ( {
148
- sources : [ { base : options . basePath , pattern : '**/*' } , ...options . sources ] ,
149
- } )
148
+ else {
149
+ let scanner = new ( oxide . Scanner as OxideV3And4 . ScannerConstructor ) ( {
150
+ sources : [
151
+ { base : options . basePath , pattern : '**/*' } ,
152
+ ...options . sources . map ( ( s ) => ( { base : s . base , pattern : s . pattern } ) ) ,
153
+ ] ,
154
+ } )
150
155
151
- return {
152
- files : scanner . files ,
153
- globs : scanner . globs ,
156
+ return {
157
+ files : scanner . files ,
158
+ sources : scanner . globs . map ( ( s ) => ( { base : s . base , pattern : s . pattern , negated : false } ) ) ,
159
+ }
154
160
}
155
161
}
0 commit comments