Skip to content

Commit

Permalink
lil tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Oct 26, 2024
1 parent 4e4c111 commit 5dcf522
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 45 deletions.
42 changes: 9 additions & 33 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { error, handleError } from "../utils/errors.js";
import type { Config } from "../utils/get-config.js";
import * as cliConfig from "../utils/get-config.js";
import { intro, prettifyList } from "../utils/prompt-helpers.js";
import { cancel, intro, prettifyList } from "../utils/prompt-helpers.js";
import * as p from "../utils/prompts.js";
import * as registry from "../utils/registry/index.js";
import { resolveImport } from "../utils/resolve-imports.js";
Expand Down Expand Up @@ -154,10 +154,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
})),
});

if (p.isCancel(input)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(input)) cancel();

style = input;
}
Expand All @@ -175,10 +172,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
})),
});

if (p.isCancel(input)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(input)) cancel();

tailwindBaseColor = input;
}
Expand All @@ -201,10 +195,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
},
});

if (p.isCancel(input)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(input)) cancel();

globalCss = input;
}
Expand All @@ -227,10 +218,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
},
});

if (p.isCancel(input)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(input)) cancel();

tailwindConfig = input;
}
Expand All @@ -245,10 +233,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
validate: (value) => validateImportAlias(value, langConfig),
});

if (p.isCancel(promptResult)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(promptResult)) cancel();

componentAlias = promptResult;
}
Expand All @@ -267,10 +252,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
validate: (value) => validateImportAlias(value, langConfig),
});

if (p.isCancel(input)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(input)) cancel();

utilsAlias = input;
}
Expand All @@ -285,10 +267,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
validate: (value) => validateImportAlias(value, langConfig),
});

if (p.isCancel(input)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(input)) cancel();

hooksAlias = input;
}
Expand All @@ -303,10 +282,7 @@ async function promptForConfig(cwd: string, defaultConfig: Config | null, option
validate: (value) => validateImportAlias(value, langConfig),
});

if (p.isCancel(input)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(input)) cancel();

uiAlias = input;
}
Expand Down
12 changes: 3 additions & 9 deletions packages/cli/src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { detectPM } from "../utils/auto-detect.js";
import { error, handleError } from "../utils/errors.js";
import * as cliConfig from "../utils/get-config.js";
import { getEnvProxy } from "../utils/get-env-proxy.js";
import { intro, prettifyList } from "../utils/prompt-helpers.js";
import { cancel, intro, prettifyList } from "../utils/prompt-helpers.js";
import * as p from "../utils/prompts.js";
import * as registry from "../utils/registry/index.js";
import { UTILS, UTILS_JS } from "../utils/templates.js";
Expand Down Expand Up @@ -132,10 +132,7 @@ async function runUpdate(cwd: string, config: cliConfig.Config, options: UpdateO
})),
});

if (p.isCancel(selected)) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(selected)) cancel();

selectedComponents = selected;
} else {
Expand All @@ -149,10 +146,7 @@ async function runUpdate(cwd: string, config: cliConfig.Config, options: UpdateO
initialValue: true,
});

if (p.isCancel(proceed) || proceed === false) {
p.cancel("Operation cancelled.");
process.exit(0);
}
if (p.isCancel(proceed) || proceed === false) cancel();
}

// `update utils` - update the utils.(ts|js) file
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/src/utils/auto-detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ export async function detectPM(cwd: string, prompt: boolean): Promise<Agent | un
message: "Which package manager do you want to use?",
options,
});
if (p.isCancel(res)) {
cancel();
}
if (p.isCancel(res)) cancel();

agent = res;
}
Expand Down

0 comments on commit 5dcf522

Please sign in to comment.