@@ -9,16 +9,16 @@ import { StringDecoder } from 'string_decoder';
99import * as tk from 'tree-kill' ;
1010import * as util from 'util' ;
1111import { CancellationToken , Disposable } from 'vscode' ;
12- import { BQRSInfo , DecodedBqrsChunk } from " ./bqrs-cli-types" ;
13- import { DistributionProvider } from " ./distribution" ;
14- import { assertNever } from " ./helpers-pure" ;
15- import { QueryMetadata , SortDirection } from " ./interface-types" ;
16- import { Logger , ProgressReporter } from " ./logging" ;
12+ import { BQRSInfo , DecodedBqrsChunk } from ' ./bqrs-cli-types' ;
13+ import { DistributionProvider } from ' ./distribution' ;
14+ import { assertNever } from ' ./helpers-pure' ;
15+ import { QueryMetadata , SortDirection } from ' ./interface-types' ;
16+ import { Logger , ProgressReporter } from ' ./logging' ;
1717
1818/**
1919 * The version of the SARIF format that we are using.
2020 */
21- const SARIF_FORMAT = " sarifv2.1.0" ;
21+ const SARIF_FORMAT = ' sarifv2.1.0' ;
2222
2323/**
2424 * Flags to pass to all cli commands.
@@ -131,7 +131,7 @@ export class CodeQLCliServer implements Disposable {
131131 // Tell the Java CLI server process to shut down.
132132 this . logger . log ( 'Sending shutdown request' ) ;
133133 try {
134- this . process . stdin . write ( JSON . stringify ( [ " shutdown" ] ) , " utf8" ) ;
134+ this . process . stdin . write ( JSON . stringify ( [ ' shutdown' ] ) , ' utf8' ) ;
135135 this . process . stdin . write ( this . nullBuffer ) ;
136136 this . logger . log ( 'Sent shutdown request' ) ;
137137 } catch ( e ) {
@@ -188,13 +188,13 @@ export class CodeQLCliServer implements Disposable {
188188 */
189189 private async launchProcess ( ) : Promise < child_process . ChildProcessWithoutNullStreams > {
190190 const config = await this . getCodeQlPath ( ) ;
191- return spawnServer ( config , " CodeQL CLI Server" , [ " execute" , " cli-server" ] , [ ] , this . logger , _data => { /**/ } ) ;
191+ return spawnServer ( config , ' CodeQL CLI Server' , [ ' execute' , ' cli-server' ] , [ ] , this . logger , _data => { /**/ } ) ;
192192 }
193193
194194 private async runCodeQlCliInternal ( command : string [ ] , commandArgs : string [ ] , description : string ) : Promise < string > {
195195 const stderrBuffers : Buffer [ ] = [ ] ;
196196 if ( this . commandInProcess ) {
197- throw new Error ( " runCodeQlCliInternal called while cli was running" ) ;
197+ throw new Error ( ' runCodeQlCliInternal called while cli was running' ) ;
198198 }
199199 this . commandInProcess = true ;
200200 try {
@@ -209,7 +209,7 @@ export class CodeQLCliServer implements Disposable {
209209
210210 // Compute the full args array
211211 const args = command . concat ( LOGGING_FLAGS ) . concat ( commandArgs ) ;
212- const argsString = args . join ( " " ) ;
212+ const argsString = args . join ( ' ' ) ;
213213 this . logger . log ( `${ description } using CodeQL CLI: ${ argsString } ...` ) ;
214214 try {
215215 await new Promise ( ( resolve , reject ) => {
@@ -228,16 +228,16 @@ export class CodeQLCliServer implements Disposable {
228228 stderrBuffers . push ( newData ) ;
229229 } ) ;
230230 // Listen for process exit.
231- process . addListener ( " close" , ( code ) => reject ( code ) ) ;
231+ process . addListener ( ' close' , ( code ) => reject ( code ) ) ;
232232 // Write the command followed by a null terminator.
233- process . stdin . write ( JSON . stringify ( args ) , " utf8" ) ;
233+ process . stdin . write ( JSON . stringify ( args ) , ' utf8' ) ;
234234 process . stdin . write ( this . nullBuffer ) ;
235235 } ) ;
236236 // Join all the data together
237237 const fullBuffer = Buffer . concat ( stdoutBuffers ) ;
238238 // Make sure we remove the terminator;
239- const data = fullBuffer . toString ( " utf8" , 0 , fullBuffer . length - 1 ) ;
240- this . logger . log ( ` CLI command succeeded.` ) ;
239+ const data = fullBuffer . toString ( ' utf8' , 0 , fullBuffer . length - 1 ) ;
240+ this . logger . log ( ' CLI command succeeded.' ) ;
241241 return data ;
242242 } catch ( err ) {
243243 // Kill the process if it isn't already dead.
@@ -246,15 +246,15 @@ export class CodeQLCliServer implements Disposable {
246246 const newError =
247247 stderrBuffers . length == 0
248248 ? new Error ( `${ description } failed: ${ err } ` )
249- : new Error ( `${ description } failed: ${ Buffer . concat ( stderrBuffers ) . toString ( " utf8" ) } ` ) ;
249+ : new Error ( `${ description } failed: ${ Buffer . concat ( stderrBuffers ) . toString ( ' utf8' ) } ` ) ;
250250 newError . stack += ( err . stack || '' ) ;
251251 throw newError ;
252252 } finally {
253- this . logger . log ( Buffer . concat ( stderrBuffers ) . toString ( " utf8" ) ) ;
253+ this . logger . log ( Buffer . concat ( stderrBuffers ) . toString ( ' utf8' ) ) ;
254254 // Remove the listeners we set up.
255255 process . stdout . removeAllListeners ( 'data' ) ;
256256 process . stderr . removeAllListeners ( 'data' ) ;
257- process . removeAllListeners ( " close" ) ;
257+ process . removeAllListeners ( ' close' ) ;
258258 }
259259 } finally {
260260 this . commandInProcess = false ;
@@ -413,10 +413,10 @@ export class CodeQLCliServer implements Disposable {
413413 async resolveLibraryPath ( workspaces : string [ ] , queryPath : string ) : Promise < QuerySetup > {
414414 const subcommandArgs = [
415415 '--query' , queryPath ,
416- " --additional-packs" ,
416+ ' --additional-packs' ,
417417 workspaces . join ( path . delimiter )
418418 ] ;
419- return await this . runJsonCodeQlCliCommand < QuerySetup > ( [ 'resolve' , 'library-path' ] , subcommandArgs , " Resolving library paths" ) ;
419+ return await this . runJsonCodeQlCliCommand < QuerySetup > ( [ 'resolve' , 'library-path' ] , subcommandArgs , ' Resolving library paths' ) ;
420420 }
421421
422422 /**
@@ -458,7 +458,7 @@ export class CodeQLCliServer implements Disposable {
458458 * @param queryPath The path to the query.
459459 */
460460 async resolveMetadata ( queryPath : string ) : Promise < QueryMetadata > {
461- return await this . runJsonCodeQlCliCommand < QueryMetadata > ( [ 'resolve' , 'metadata' ] , [ queryPath ] , " Resolving query metadata" ) ;
461+ return await this . runJsonCodeQlCliCommand < QueryMetadata > ( [ 'resolve' , 'metadata' ] , [ queryPath ] , ' Resolving query metadata' ) ;
462462 }
463463
464464 /**
@@ -474,7 +474,7 @@ export class CodeQLCliServer implements Disposable {
474474 if ( queryMemoryMb !== undefined ) {
475475 args . push ( '--ram' , queryMemoryMb . toString ( ) ) ;
476476 }
477- return await this . runJsonCodeQlCliCommand < string [ ] > ( [ 'resolve' , 'ram' ] , args , " Resolving RAM settings" , progressReporter ) ;
477+ return await this . runJsonCodeQlCliCommand < string [ ] > ( [ 'resolve' , 'ram' ] , args , ' Resolving RAM settings' , progressReporter ) ;
478478 }
479479 /**
480480 * Gets the headers (and optionally pagination info) of a bqrs.
@@ -483,11 +483,11 @@ export class CodeQLCliServer implements Disposable {
483483 */
484484 async bqrsInfo ( bqrsPath : string , pageSize ?: number ) : Promise < BQRSInfo > {
485485 const subcommandArgs = (
486- pageSize ? [ " --paginate-rows" , pageSize . toString ( ) ] : [ ]
486+ pageSize ? [ ' --paginate-rows' , pageSize . toString ( ) ] : [ ]
487487 ) . concat (
488488 bqrsPath
489489 ) ;
490- return await this . runJsonCodeQlCliCommand < BQRSInfo > ( [ 'bqrs' , 'info' ] , subcommandArgs , " Reading bqrs header" ) ;
490+ return await this . runJsonCodeQlCliCommand < BQRSInfo > ( [ 'bqrs' , 'info' ] , subcommandArgs , ' Reading bqrs header' ) ;
491491 }
492492
493493 /**
@@ -499,37 +499,37 @@ export class CodeQLCliServer implements Disposable {
499499 */
500500 async bqrsDecode ( bqrsPath : string , resultSet : string , pageSize ?: number , offset ?: number ) : Promise < DecodedBqrsChunk > {
501501 const subcommandArgs = [
502- " --entities=url,string" ,
503- " --result-set" , resultSet ,
502+ ' --entities=url,string' ,
503+ ' --result-set' , resultSet ,
504504 ] . concat (
505- pageSize ? [ " --rows" , pageSize . toString ( ) ] : [ ]
505+ pageSize ? [ ' --rows' , pageSize . toString ( ) ] : [ ]
506506 ) . concat (
507- offset ? [ " --start-at" , offset . toString ( ) ] : [ ]
507+ offset ? [ ' --start-at' , offset . toString ( ) ] : [ ]
508508 ) . concat ( [ bqrsPath ] ) ;
509- return await this . runJsonCodeQlCliCommand < DecodedBqrsChunk > ( [ 'bqrs' , 'decode' ] , subcommandArgs , " Reading bqrs data" ) ;
509+ return await this . runJsonCodeQlCliCommand < DecodedBqrsChunk > ( [ 'bqrs' , 'decode' ] , subcommandArgs , ' Reading bqrs data' ) ;
510510 }
511511
512512
513513 async interpretBqrs ( metadata : { kind : string ; id : string } , resultsPath : string , interpretedResultsPath : string , sourceInfo ?: SourceInfo ) : Promise < sarif . Log > {
514514 const args = [
515515 `-t=kind=${ metadata . kind } ` ,
516516 `-t=id=${ metadata . id } ` ,
517- " --output" , interpretedResultsPath ,
518- " --format" , SARIF_FORMAT ,
517+ ' --output' , interpretedResultsPath ,
518+ ' --format' , SARIF_FORMAT ,
519519 // TODO: This flag means that we don't group interpreted results
520520 // by primary location. We may want to revisit whether we call
521521 // interpretation with and without this flag, or do some
522522 // grouping client-side.
523- " --no-group-results" ,
523+ ' --no-group-results' ,
524524 ] ;
525525 if ( sourceInfo !== undefined ) {
526526 args . push (
527- " --source-archive" , sourceInfo . sourceArchive ,
528- " --source-location-prefix" , sourceInfo . sourceLocationPrefix
527+ ' --source-archive' , sourceInfo . sourceArchive ,
528+ ' --source-location-prefix' , sourceInfo . sourceLocationPrefix
529529 ) ;
530530 }
531531 args . push ( resultsPath ) ;
532- await this . runCodeQlCliCommand ( [ 'bqrs' , 'interpret' ] , args , " Interpreting query results" ) ;
532+ await this . runCodeQlCliCommand ( [ 'bqrs' , 'interpret' ] , args , ' Interpreting query results' ) ;
533533
534534 let output : string ;
535535 try {
@@ -549,24 +549,24 @@ export class CodeQLCliServer implements Disposable {
549549 const sortDirectionStrings = sortDirections . map ( direction => {
550550 switch ( direction ) {
551551 case SortDirection . asc :
552- return " asc" ;
552+ return ' asc' ;
553553 case SortDirection . desc :
554- return " desc" ;
554+ return ' desc' ;
555555 default :
556556 return assertNever ( direction ) ;
557557 }
558558 } ) ;
559559
560560 await this . runCodeQlCliCommand ( [ 'bqrs' , 'decode' ] ,
561561 [
562- " --format=bqrs" ,
562+ ' --format=bqrs' ,
563563 `--result-set=${ resultSet } ` ,
564564 `--output=${ sortedResultsPath } ` ,
565- `--sort-key=${ sortKeys . join ( "," ) } ` ,
566- `--sort-direction=${ sortDirectionStrings . join ( "," ) } ` ,
565+ `--sort-key=${ sortKeys . join ( ',' ) } ` ,
566+ `--sort-direction=${ sortDirectionStrings . join ( ',' ) } ` ,
567567 resultsPath
568568 ] ,
569- " Sorting query results" ) ;
569+ ' Sorting query results' ) ;
570570 }
571571
572572
@@ -576,7 +576,7 @@ export class CodeQLCliServer implements Disposable {
576576 */
577577 resolveDatabase ( databasePath : string ) : Promise < DbInfo > {
578578 return this . runJsonCodeQlCliCommand ( [ 'resolve' , 'database' ] , [ databasePath ] ,
579- " Resolving database" ) ;
579+ ' Resolving database' ) ;
580580 }
581581
582582 /**
@@ -591,7 +591,7 @@ export class CodeQLCliServer implements Disposable {
591591 return this . runJsonCodeQlCliCommand < UpgradesInfo > (
592592 [ 'resolve' , 'upgrades' ] ,
593593 args ,
594- " Resolving database upgrade scripts" ,
594+ ' Resolving database upgrade scripts' ,
595595 ) ;
596596 }
597597
@@ -611,7 +611,7 @@ export class CodeQLCliServer implements Disposable {
611611 return this . runJsonCodeQlCliCommand < QlpacksInfo > (
612612 [ 'resolve' , 'qlpacks' ] ,
613613 args ,
614- " Resolving qlpack information" ,
614+ ' Resolving qlpack information' ,
615615 ) ;
616616 }
617617
@@ -632,7 +632,7 @@ export class CodeQLCliServer implements Disposable {
632632 return this . runJsonCodeQlCliCommand < string [ ] > (
633633 [ 'resolve' , 'queries' ] ,
634634 args ,
635- " Resolving queries" ,
635+ ' Resolving queries' ,
636636 ) ;
637637 }
638638}
@@ -666,7 +666,7 @@ export function spawnServer(
666666
667667 // Start the server process.
668668 const base = codeqlPath ;
669- const argsString = args . join ( " " ) ;
669+ const argsString = args . join ( ' ' ) ;
670670 if ( progressReporter !== undefined ) {
671671 progressReporter . report ( { message : `Starting ${ name } ` } ) ;
672672 }
@@ -703,15 +703,15 @@ export function spawnServer(
703703export async function runCodeQlCliCommand ( codeQlPath : string , command : string [ ] , commandArgs : string [ ] , description : string , logger : Logger , progressReporter ?: ProgressReporter ) : Promise < string > {
704704 // Add logging arguments first, in case commandArgs contains positional parameters.
705705 const args = command . concat ( LOGGING_FLAGS ) . concat ( commandArgs ) ;
706- const argsString = args . join ( " " ) ;
706+ const argsString = args . join ( ' ' ) ;
707707 try {
708708 if ( progressReporter !== undefined ) {
709709 progressReporter . report ( { message : description } ) ;
710710 }
711711 logger . log ( `${ description } using CodeQL CLI: ${ codeQlPath } ${ argsString } ...` ) ;
712712 const result = await util . promisify ( child_process . execFile ) ( codeQlPath , args ) ;
713713 logger . log ( result . stderr ) ;
714- logger . log ( ` CLI command succeeded.` ) ;
714+ logger . log ( ' CLI command succeeded.' ) ;
715715 return result . stdout ;
716716 } catch ( err ) {
717717 throw new Error ( `${ description } failed: ${ err . stderr || err } ` ) ;
0 commit comments