@defer/redwood
Version:
Setup Defer in RedwoodJS
25 lines (24 loc) • 723 B
JavaScript
import { colors } from "@redwoodjs/cli-helpers";
import { tasks as setupPluginTasks } from "./tasks.js";
function isErrorWithExitCode(e) {
return typeof e?.exitCode !== "undefined";
}
export const handler = async ({ cwd, force, name }) => {
const tasks = setupPluginTasks({ cwd, force, name });
// TODO: check and format `name`
try {
await tasks.run();
}
catch (e) {
if (e instanceof Error) {
console.error(colors.error(e.message));
}
else {
console.error(colors.error("Unknown error when running yargs tasks"));
}
if (isErrorWithExitCode(e)) {
process.exit(e.exitCode);
}
process.exit(1);
}
};