UNPKG

@tsed/cli

Version:
18 lines (17 loc) 687 B
import { inject } from "@tsed/cli-core"; import { isString } from "@tsed/core"; import { pascalCase } from "change-case"; import { RoutePipe } from "../../pipes/RoutePipe.js"; import { CliProjectService } from "../CliProjectService.js"; export function addContextMethods(context) { const getName = (state) => context.name || pascalCase(state.name || context.name || state.type || context.type || ""); return { getName, getRoute: (state) => { return inject(RoutePipe).transform(isString(state) ? state : getName(state)); }, getDirectories: (dir) => { return inject(CliProjectService).getDirectories(dir); } }; }