File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import * as qs from 'qs';
11
11
import { ResponseParsingError } from '../types/errors' ;
12
12
import { ValidationResults } from '../types/validation' ;
13
13
import * as rp from 'request-promise-native' ;
14
+ import { flatMap } from 'lodash' ;
14
15
15
16
function isSwaggerV2 ( apiDoc : any ) : boolean {
16
17
return apiDoc . swagger === '2.0' ;
@@ -254,13 +255,15 @@ export interface CliFlags {
254
255
* @param flags
255
256
*/
256
257
export function buildCliArguments ( flags : Array < CliFlags > ) : Array < string > {
257
- return flags
258
- . filter ( ( { value } ) => typeof value === 'string' || value === true )
259
- . flatMap ( ( { flag, value } ) => {
260
- const args = [ flag ] ;
261
- if ( typeof value === 'string' ) {
262
- args . push ( value ) ;
263
- }
264
- return args ;
265
- } ) ;
258
+ const effectiveFlags = flags . filter (
259
+ ( { value } ) => typeof value === 'string' || value === true ,
260
+ ) ;
261
+
262
+ return flatMap ( effectiveFlags , ( { flag, value } ) => {
263
+ const args = [ flag ] ;
264
+ if ( typeof value === 'string' ) {
265
+ args . push ( value ) ;
266
+ }
267
+ return args ;
268
+ } ) ;
266
269
}
Original file line number Diff line number Diff line change 1
1
import { exec as _exec } from 'child_process' ;
2
2
import * as util from 'util' ;
3
+ import { flatMap } from 'lodash' ;
3
4
import findProcess = require( 'find-process' ) ;
4
5
5
6
const exec = util . promisify ( _exec ) ;
6
7
7
- export async function killNodeProcesses ( ports : Array < string | number > ) : Promise < any > {
8
+ export async function killNodeProcesses (
9
+ ports : Array < string | number > ,
10
+ ) : Promise < any > {
8
11
const processResults = await Promise . all (
9
12
ports . map ( ( port ) => findProcess ( 'port' , port ) ) ,
10
13
) ;
11
14
return killProcesses (
12
- processResults . flatMap ( ( results ) =>
13
- results . flatMap ( ( process ) =>
15
+ flatMap ( processResults , ( results ) =>
16
+ flatMap ( results , ( process ) =>
14
17
process . cmd . includes ( 'node' ) ? process . pid : [ ] ,
15
18
) ,
16
19
) ,
You can’t perform that action at this time.
0 commit comments