Skip to content

Commit

Permalink
fix(check_redirects): make the checks fail fast (#7226)
Browse files Browse the repository at this point in the history
  • Loading branch information
OnkarRuikar committed Nov 7, 2022
1 parent d20c8dd commit 33c907f
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions tool/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,26 @@ program
tryOrExit(({ args, options, logger }) => {
const { locales } = args;
const { strict } = options;
let fine = true;
if (strict) {
for (const locale of locales) {
try {
Redirect.validateLocale(locale, strict);
logger.info(chalk.green(`✓ redirects for ${locale} looking good!`));
} catch (e) {
logger.info(
chalk.red(`_redirects.txt for ${locale} is causing issues: ${e}`)
throw new Error(
`_redirects.txt for ${locale} is causing issues: ${e}`
);
fine = false;
}
}
} else {
try {
Redirect.load(locales, true);
} catch (e) {
logger.info(chalk.red(`Unable to load redirects: ${e}`));
fine = false;
throw new Error(`Unable to load redirects: ${e}`);
}
}
if (fine) {
logger.info(chalk.green("🍾 All is well in the world of redirects 🥂"));
} else {
throw new Error("🔥 Errors loading redirects 🔥");
}

logger.info(chalk.green("🍾 All is well in the world of redirects 🥂"));
})
)

Expand Down

0 comments on commit 33c907f

Please sign in to comment.