@@ -137,10 +137,12 @@ async function createPythonVenv(venvPath: string): Promise<boolean> {
137137 const venvCmd = `${ getSystemPythonBinName ( ) } -m venv ${ VIRTUAL_ENVIRONMENT_DIR } ` ;
138138
139139 for ( const cmd of [ venvCmd , pipCmd ] ) {
140+ const spinner = getStartedSpinner ( ) ;
140141 const { err, stdout, stderr} = await new Promise < { err : exec . ExecException | null , stdout : string , stderr : string } > ( resolve => {
141142 exec . exec ( cmd , ( err , stdout , stderr ) => resolve ( { err, stdout, stderr} ) ) ;
142143 } ) ;
143144
145+ stopSpinner ( spinner ) ;
144146 console . log ( `${ stdout } ` ) ;
145147
146148 if ( err ) {
@@ -176,6 +178,7 @@ async function setup(projectRoot: string) {
176178 * @param parserArgs the list of arguments passed to this command.
177179 */
178180async function runGlean ( projectRoot : string , parserArgs : string [ ] ) {
181+ const spinner = getStartedSpinner ( ) ;
179182 const venvRoot = path . join ( projectRoot , VIRTUAL_ENVIRONMENT_DIR ) ;
180183 const pythonBin = path . join ( getPythonVenvBinariesPath ( venvRoot ) , getSystemPythonBinName ( ) ) ;
181184 const cmd = `${ pythonBin } -c "${ PYTHON_SCRIPT } " online glean_parser ${ GLEAN_PARSER_VERSION } ${ parserArgs . join ( " " ) } ` ;
@@ -184,6 +187,7 @@ async function runGlean(projectRoot: string, parserArgs: string[]) {
184187 exec . exec ( cmd , ( err , stdout , stderr ) => resolve ( { err, stdout, stderr} ) ) ;
185188 } ) ;
186189
190+ stopSpinner ( spinner ) ;
187191 console . log ( `${ stdout } ` ) ;
188192
189193 if ( err ) {
@@ -214,3 +218,27 @@ async function run(args: string[]) {
214218run ( argv ) . catch ( e => {
215219 console . error ( "There was an error running Glean" , e ) ;
216220} ) ;
221+
222+ /**
223+ * Returns a spinner
224+ *
225+ * @returns an Interval ID that logs certain characters
226+ */
227+ function getStartedSpinner ( ) {
228+ const ticks = [ "\\" , "|" , "/" , "-" ] ;
229+ let i = 0 ;
230+ return setInterval ( function ( ) {
231+ process . stdout . write ( " " + ticks [ i ++ ] + "\r\r" ) ;
232+ i %= 4 ;
233+ } , 250 ) ;
234+ }
235+
236+ /**
237+ * Stops the spinner
238+ *
239+ * @param spinner is created by getStartedSpinner
240+ */
241+ function stopSpinner ( spinner : NodeJS . Timeout ) {
242+ process . stdout . write ( " \r" ) ;
243+ clearInterval ( spinner ) ;
244+ }
0 commit comments