-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "move lint to perennial-alias instead of chipper and fix peren…
…nial `grunt lint`, phetsims/chipper#1286" This reverts commit e684c0d.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2022, University of Colorado Boulder | ||
|
||
/** | ||
* Helper function to show a progress bar on the command line. | ||
* @author Sam Reid (PhET Interactive Simulations) | ||
* @author Michael Kauzmann (PhET Interactive Simulations) | ||
*/ | ||
|
||
/* eslint-env node */ | ||
const _ = require( 'lodash' ); // eslint-disable-line | ||
|
||
/** | ||
* See https://jagascript.com/how-to-build-a-textual-progress-bar-for-cli-and-terminal-apps/ | ||
* @param {number} progress - decimal between 0 and 1 | ||
* @param {boolean} newline - if each new progress should give a new line, should be false during progress, and true when finally completed | ||
* @param {Object} [options] | ||
*/ | ||
module.exports = function showCommandLineProgress( progress, newline, options ) { | ||
options = _.extend( { | ||
progressBarLength: 40 // in characters | ||
}, options ); | ||
|
||
const dots = '.'.repeat( Math.round( progress * options.progressBarLength ) ); | ||
const empty = ' '.repeat( Math.round( ( 1 - progress ) * options.progressBarLength ) ); | ||
const newlineString = newline ? '\n' : ''; | ||
process.stdout.write( `\r[${dots}${empty}] ${( progress * 100 ).toFixed( 2 )}%${newlineString}` ); | ||
}; |