@@ -10,9 +10,6 @@ import * as path from "path";
1010import { argv , platform } from "process" ;
1111import { promisify } from "util" ;
1212
13- // Define an async/await version of "exec".
14- const execAsync = promisify ( exec . exec ) ;
15-
1613// The name of the directory which will contain the Python virtual environment
1714// used to run the glean-parser.
1815const VIRTUAL_ENVIRONMENT_DIR = ".venv" ;
@@ -140,10 +137,12 @@ async function createPythonVenv(venvPath: string): Promise<boolean> {
140137 const venvCmd = `${ getSystemPythonBinName ( ) } -m venv ${ VIRTUAL_ENVIRONMENT_DIR } ` ;
141138
142139 for ( const cmd of [ venvCmd , pipCmd ] ) {
143- try {
144- await execAsync ( cmd ) ;
145- } catch ( e ) {
146- console . error ( e ) ;
140+ const { err, stdout, stderr} = await new Promise < { err : exec . ExecException | null , stdout : string , stderr : string } > ( resolve => {
141+ exec . exec ( cmd , ( err , stdout , stderr ) => resolve ( { err, stdout, stderr} ) ) ;
142+ } ) ;
143+
144+ if ( err ) {
145+ console . error ( `${ stdout } \n${ stderr } ` ) ;
147146 return false ;
148147 }
149148 }
@@ -178,10 +177,13 @@ async function runGlean(projectRoot: string, parserArgs: string[]) {
178177 const venvRoot = path . join ( projectRoot , VIRTUAL_ENVIRONMENT_DIR ) ;
179178 const pythonBin = path . join ( getPythonVenvBinariesPath ( venvRoot ) , getSystemPythonBinName ( ) ) ;
180179 const cmd = `${ pythonBin } -c "${ PYTHON_SCRIPT } " online glean_parser ${ GLEAN_PARSER_VERSION } ${ parserArgs . join ( " " ) } ` ;
181- try {
182- await execAsync ( cmd ) ;
183- } catch ( e ) {
184- console . error ( e ) ;
180+
181+ const { err, stdout, stderr} = await new Promise < { err : exec . ExecException | null , stdout : string , stderr : string } > ( resolve => {
182+ exec . exec ( cmd , ( err , stdout , stderr ) => resolve ( { err, stdout, stderr} ) ) ;
183+ } ) ;
184+
185+ if ( err ) {
186+ console . error ( `${ stdout } \n${ stderr } ` ) ;
185187 }
186188}
187189
0 commit comments