3636 *
3737 */
3838
39- const assert = require ( "chai" ) . assert ;
40- const colors = require ( "colors/safe" ) ;
41- const path = require ( "path" ) ;
39+ const assert = require ( "chai" ) . assert ;
40+ const path = require ( "path" ) ;
4241
4342const GitUtil = require ( "./git_util" ) ;
4443const SequencerState = require ( "./sequencer_state" ) ;
4544const RepoStatus = require ( "./repo_status" ) ;
4645const TextUtil = require ( "./text_util" ) ;
46+ const ColorHandler = require ( "./color_handler" ) . ColorHandler ;
47+
4748
4849/**
4950 * This value-semantic class describes a line entry to be printed in a status
@@ -383,7 +384,14 @@ A ${command} is in progress.
383384 * @param {RepoStatus } status
384385 * @return {String>
385386 */
386- exports . printCurrentBranch = function ( status ) {
387+ exports . printCurrentBranch = function ( status , options ) {
388+ // fill in default value
389+ if ( options === undefined ) { options = { } ; }
390+ if ( options . colors === undefined ) {
391+ options . colors = new ColorHandler ( ) ;
392+ }
393+ let colors = options . colors ;
394+
387395 if ( null !== status . currentBranchName ) {
388396 return `On branch ${ colors . green ( status . currentBranchName ) } .\n` ;
389397 }
@@ -399,16 +407,26 @@ On detached head ${colors.red(GitUtil.shortSha(status.headCommit))}.\n`;
399407 * the specified `cwd`. Note that a value of "" for `cwd` indicates the root
400408 * of the repository.
401409 *
402- * @param {RepoStatus } status
403- * @param {String } cwd
410+ * @param {RepoStatus } status
411+ * @param {String } cwd
412+ * @param {Object } [options]
413+ * @param {ColorHandler } [options.colors]
404414 */
405- exports . printRepoStatus = function ( status , cwd ) {
415+ exports . printRepoStatus = function ( status , cwd , options ) {
406416 assert . instanceOf ( status , RepoStatus ) ;
407417 assert . isString ( cwd ) ;
408418
419+ // fill in default value
420+ if ( options === undefined ) { options = { } ; }
421+ if ( options . colors === undefined ) {
422+ options . colors = new ColorHandler ( ) ;
423+ }
424+
425+ const colors = options . colors ;
426+
409427 let result = "" ;
410428
411- result += exports . printCurrentBranch ( status ) ;
429+ result += exports . printCurrentBranch ( status , options ) ;
412430
413431 if ( null !== status . sequencerState ) {
414432 result += exports . printSequencer ( status . sequencerState ) ;
@@ -464,13 +482,23 @@ Untracked files:
464482 * paths relative to the specified `cwd`. Note that a value of "" for
465483 * `cwd` indicates the root of the repository.
466484 *
467- * @param {RepoStatus } status
468- * @param {String } cwd
485+ * @param {RepoStatus } status
486+ * @param {String } cwd
487+ * @param {Object } [options]
488+ * @param {ColorHandler } [options.colors]
469489 */
470- exports . printRepoStatusShort = function ( status , cwd ) {
490+ exports . printRepoStatusShort = function ( status , cwd , options ) {
471491 assert . instanceOf ( status , RepoStatus ) ;
472492 assert . isString ( cwd ) ;
473493
494+ // fill in default values for options
495+ if ( options === undefined ) { options = { } ; }
496+ if ( options . colors === undefined ) {
497+ options . colors = new ColorHandler ( ) ;
498+ }
499+
500+ const colors = options . colors ;
501+
474502 let result = "" ;
475503
476504 const indexChangesByPath = { } ;
@@ -540,6 +568,8 @@ exports.printSubmoduleStatus = function (relCwd,
540568 assert . isObject ( subsToPrint ) ;
541569 assert . isBoolean ( showClosed ) ;
542570
571+ const colors = new ColorHandler ( "auto" ) ;
572+
543573 let result = "" ;
544574 if ( showClosed ) {
545575 result = `${ colors . grey ( "All submodules:" ) } \n` ;
0 commit comments