Skip to content

Commit

Permalink
fix(cli): validate packages after they're provided
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-dane committed Jan 3, 2025
1 parent 0eaa112 commit c4d387f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/scripts/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ class CompassCli {
}

public async run() {
const { user, force, packages } = this.options;
const { user, force } = this.options;
const cmd = this.program.args[0];

switch (true) {
case cmd === "build": {
validatePackages(packages);
await runBuild(this.options);
break;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/scripts/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import {
getClientId,
getApiBaseUrl,
getEnvironmentAnswer,
validatePackages,
} from "@scripts/common/cli.utils";

export const runBuild = async (options: Options_Cli) => {
const pckgs =
options?.packages?.length === 0
? await getPckgsTo("build")
: (options.packages as string[]);
const pckgs = options.packages ? options.packages : await getPckgsTo("build");
validatePackages(pckgs);

if (pckgs.includes(PCKG.NODE)) {
await buildNodePckgs(options);
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/src/common/cli.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export const validateOptions = (options: Options_Cli): Options_Cli => {

export const validatePackages = (packages: string[] | undefined) => {
if (!packages) {
log.error("Packages must be defined");
log.error("Package must be defined");
process.exit(1);
}
const unsupportedPackages = packages.filter(
Expand Down

0 comments on commit c4d387f

Please sign in to comment.