forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular/cli): provide additional status messaging for ng add
This adds a spinner as well as shows more information regarding what package version was selected to be installed. Closes angular#17983
- Loading branch information
Showing
4 changed files
with
117 additions
and
32 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
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
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
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,59 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import * as ora from 'ora'; | ||
import { colors } from './color'; | ||
|
||
export class Spinner { | ||
private readonly spinner: ora.Ora; | ||
|
||
/** When false, only fail messages will be displayed. */ | ||
enabled = true; | ||
|
||
constructor(text?: string) { | ||
this.spinner = ora({ | ||
text, | ||
// The below 2 options are needed because otherwise CTRL+C will be delayed | ||
// when the underlying process is sync. | ||
hideCursor: false, | ||
discardStdin: false, | ||
}); | ||
} | ||
|
||
set text(text: string) { | ||
this.spinner.text = text; | ||
} | ||
|
||
succeed(text?: string): void { | ||
if (this.enabled) { | ||
this.spinner.succeed(text); | ||
} | ||
} | ||
|
||
info(text?: string): void { | ||
this.spinner.info(text); | ||
} | ||
|
||
fail(text?: string): void { | ||
this.spinner.fail(text && colors.redBright(text)); | ||
} | ||
|
||
warn(text?: string): void { | ||
this.spinner.fail(text && colors.yellowBright(text)); | ||
} | ||
|
||
stop(): void { | ||
this.spinner.stop(); | ||
} | ||
|
||
start(text?: string): void { | ||
if (this.enabled) { | ||
this.spinner.start(text); | ||
} | ||
} | ||
} |