@@ -10,6 +10,7 @@ import {FileTuple, FileTuples} from '../../lib/types';
10
10
11
11
export interface Options {
12
12
files : string [ ] ;
13
+ interfaces ?: string [ ] ;
13
14
isFixedMode ?: boolean ;
14
15
isOptionalAlwaysEnabled ?: boolean ;
15
16
}
@@ -33,7 +34,7 @@ export class Intermock {
33
34
}
34
35
35
36
mock ( property : string , syntaxType : ts . SyntaxKind , mockType : string ) {
36
- const smartMockType = _ . get ( smartProps , property ) ;
37
+ const smartMockType = smartProps [ property ] ;
37
38
const isFixedMode =
38
39
this . options . isFixedMode ? this . options . isFixedMode : false ;
39
40
@@ -226,6 +227,18 @@ export class Intermock {
226
227
child => this . traverseInterfaceMembers ( child , output , sourceFile ) ) ;
227
228
}
228
229
230
+ isSpecificInterface ( name : string ) {
231
+ if ( ! this . options . interfaces ) {
232
+ return true ;
233
+ }
234
+
235
+ if ( ! _ . includes ( this . options . interfaces , name ) ) {
236
+ return false ;
237
+ }
238
+
239
+ return true ;
240
+ }
241
+
229
242
processFile ( sourceFile : ts . SourceFile , output : any , propToTraverse ?: string ) {
230
243
const processNode = ( node : ts . Node ) => {
231
244
switch ( node . kind ) {
@@ -234,9 +247,12 @@ export class Intermock {
234
247
* TODO: Handle interfaces that extend others, via checking hertiage
235
248
* clauses
236
249
*/
250
+ const p = ( node as ts . InterfaceDeclaration ) . name . text ;
251
+ if ( ! this . isSpecificInterface ( p ) ) {
252
+ return ;
253
+ }
237
254
if ( propToTraverse ) {
238
- const path = ( node as ts . InterfaceDeclaration ) . name . text ;
239
- if ( path === propToTraverse ) {
255
+ if ( p === propToTraverse ) {
240
256
this . traverseInterface ( node , output , sourceFile , propToTraverse ) ;
241
257
}
242
258
} else {
@@ -247,6 +263,10 @@ export class Intermock {
247
263
const type = ( node as ts . TypeAliasDeclaration ) . type ;
248
264
const path = ( node as ts . TypeAliasDeclaration ) . name . text ;
249
265
266
+ if ( ! this . isSpecificInterface ( path ) ) {
267
+ return ;
268
+ }
269
+
250
270
if ( propToTraverse ) {
251
271
if ( path === propToTraverse ) {
252
272
this . traverseInterface ( type , output , sourceFile , propToTraverse ) ;
@@ -278,6 +298,7 @@ export class Intermock {
278
298
279
299
processNode ( sourceFile ) ;
280
300
}
301
+
281
302
async generate ( ) {
282
303
const output : any = { } ;
283
304
const fileContents = await this . readFiles ( ) ;
0 commit comments