@@ -26,7 +26,7 @@ const findBy = {
2626 skipSelf : true
2727 } )
2828 }
29- } as Record < FindMethod , ( value : string | number , config : FindConfig ) => Promise < ProcessInfo [ ] > >
29+ } as Record < FindMethod , ( value : string | RegExp | number , config : FindConfig ) => Promise < ProcessInfo [ ] > >
3030
3131/**
3232 * find process by condition
@@ -47,12 +47,18 @@ const findBy = {
4747 * @param {Boolean|Option }
4848 * @return {Promise }
4949 */
50- function find ( by : FindMethod , value : string | number , options ?: FindConfig | boolean ) : Promise < ProcessInfo [ ] > {
50+ function find ( by : FindMethod , value : string | RegExp | number , options ?: FindConfig | boolean ) : Promise < ProcessInfo [ ] > {
5151 const config : FindConfig = Object . assign ( {
5252 logLevel : 'warn' as const ,
5353 strict : typeof options === 'boolean' ? options : false
5454 } , typeof options === 'object' ? options : { } )
5555
56+ // strict is applicable only when finding by name and the value is a string,
57+ // in all other cases whatever is passed is overwritten to false
58+ if ( by !== 'name' || typeof value !== 'string' ) {
59+ config . strict = false ;
60+ }
61+
5662 if ( config . logLevel ) {
5763 log . setLevel ( config . logLevel )
5864 }
@@ -67,7 +73,7 @@ function find(by: FindMethod, value: string | number, options?: FindConfig | boo
6773 } else if ( by === 'port' && ! isNumber ) {
6874 reject ( new Error ( 'port must be a number' ) )
6975 } else {
70- findBy [ by ] ( value as any , config ) . then ( resolve , reject )
76+ findBy [ by ] ( value , config ) . then ( resolve , reject )
7177 }
7278 }
7379 } )
0 commit comments