@@ -82,7 +82,7 @@ import { makeTemporaryToolkitFolder } from '../../shared'
8282import globals from '../../shared/extensionGlobals'
8383import { convertDateToTimestamp } from '../../shared/datetime'
8484import { isWin } from '../../shared/vscode/env'
85- import { ChildProcess } from '../../shared/utilities/processUtils '
85+ import { findStringInDirectory } from '../../shared/utilities/workspaceUtils '
8686
8787function getFeedbackCommentData ( ) {
8888 const jobId = transformByQState . getJobId ( )
@@ -745,31 +745,19 @@ export async function getValidSQLConversionCandidateProjects() {
745745 } )
746746 const openProjects = await getOpenProjects ( )
747747 const javaProjects = await getJavaProjects ( openProjects )
748- let errorLog = ''
749- const isWindows = isWin ( )
750- const command = isWindows ? 'findstr' : 'grep'
748+ let resultLog = ''
751749 for ( const project of javaProjects ) {
752750 // as long as at least one of these strings is found, project contains embedded SQL statements
753751 const searchStrings = [ 'oracle.jdbc.OracleDriver' , 'jdbc:oracle:thin:@//' , 'jdbc:oracle:oci:@//' ]
754752 for ( const str of searchStrings ) {
755- // case-insensitive, recursive search
756- const args = isWindows ? [ '/i' , '/s' , str , '*.*' ] : [ '-i' , '-r' , str ]
757- const spawnResult = await new ChildProcess ( command , args ) . run ( {
758- spawnOptions : { cwd : project . path , shell : false } ,
759- } )
753+ const spawnResult = await findStringInDirectory ( str , project . path )
760754 // just for telemetry purposes
761755 if ( spawnResult . error || spawnResult . stderr ) {
762- errorLog += `${ JSON . stringify ( spawnResult ) } --- `
756+ resultLog += `search failed: ${ JSON . stringify ( spawnResult ) } `
763757 } else {
764- errorLog += `${ command } succeeded: ${ spawnResult . exitCode } `
758+ resultLog += `search succeeded: ${ spawnResult . exitCode } `
765759 }
766- /*
767- note:
768- error is set when command fails to spawn; stderr is set when command itself fails.
769- status of 0 means search string was detected (will be printed to stdout).
770- status will be non-zero and stdout / stderr / error will be empty when search string is not detected.
771- */
772- getLogger ( ) . info ( `CodeTransformation: searching for ${ str } in ${ project . path } , result = ${ errorLog } ` )
760+ getLogger ( ) . info ( `CodeTransformation: searching for ${ str } in ${ project . path } , result = ${ resultLog } ` )
773761 if ( spawnResult . exitCode === 0 ) {
774762 embeddedSQLProjects . push ( project )
775763 break
@@ -780,7 +768,7 @@ export async function getValidSQLConversionCandidateProjects() {
780768 `CodeTransformation: found ${ embeddedSQLProjects . length } projects with embedded SQL statements`
781769 )
782770 telemetry . record ( {
783- codeTransformMetadata : errorLog ,
771+ codeTransformMetadata : resultLog ,
784772 } )
785773 } )
786774 return embeddedSQLProjects
0 commit comments