UNPKG

winterspec

Version:

Write Winter-CG compatible routes with filesystem routing and tons of features

31 lines (30 loc) 1.13 kB
import { Command, Option } from "clipanion"; import * as t from "typanion"; import { loadConfig } from "../config/utils.js"; export class BaseCommand extends Command { constructor() { super(...arguments); this.rootDirectory = Option.String("--root", { description: "Path to your project root", }); this.tsconfigPath = Option.String("--tsconfig", { description: "Path to your tsconfig.json", }); this.routesDirectory = Option.String("--routes-directory", { description: "Path to your routes directory", }); this.platform = Option.String("--platform", { description: "The platform to bundle for", validator: t.isEnum(["node", "wintercg-minimal"]), }); } async execute() { const overrides = { tsconfigPath: this.tsconfigPath, routesDirectory: this.routesDirectory, rootDirectory: this.rootDirectory, platform: this.platform, }; return this.run(await loadConfig(this.rootDirectory ?? process.cwd(), overrides)); } }