Skip to content

Commit

Permalink
feat(command): add support for disabling spinner in upgrade command (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar authored Sep 28, 2024
1 parent f882fa0 commit 62fa792
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion command/upgrade/provider/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class NpmProvider extends Provider {
private readonly packageName?: string;
private readonly packageScope?: string;

constructor({ main, logger, ...options }: NpmProviderOptions) {
constructor({ main, logger, ...options }: NpmProviderOptions = {}) {
super({ main, logger });
if ("package" in options) {
if (options.package.startsWith("@")) {
Expand Down
10 changes: 7 additions & 3 deletions command/upgrade/upgrade_command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface UpgradeCommandOptions<
> extends RuntimeOptions {
provider: TProvider | Array<TProvider>;
runtime?: RuntimeOptionsMap;
spinner?: boolean;
}

/**
Expand Down Expand Up @@ -58,7 +59,8 @@ export class UpgradeCommand extends Command {
private readonly providers: ReadonlyArray<Provider>;

constructor(
{ provider, ...options }: UpgradeCommandOptions,
{ provider, spinner: withSpinner = true, ...options }:
UpgradeCommandOptions,
) {
super();
this.providers = Array.isArray(provider) ? provider : [provider];
Expand Down Expand Up @@ -108,7 +110,9 @@ export class UpgradeCommand extends Command {
"-v, --verbose",
"Log verbose output.",
)
.option("--no-spinner", "Disable spinner.")
.option("--no-spinner", "Disable spinner.", {
hidden: !withSpinner,
})
.complete("version", () => this.getAllVersions())
.action(
async (
Expand All @@ -123,7 +127,7 @@ export class UpgradeCommand extends Command {
const name: string = this.getMainCommand().getName();
const currentVersion: string | undefined = this.getVersion();

const spinner = spinnerEnabled
const spinner = withSpinner && spinnerEnabled
? new Spinner({
message: brightBlue(
`Upgrading ${bold(name)} from version ${
Expand Down

0 comments on commit 62fa792

Please sign in to comment.