import { extname, resolve } from 'path' import type { GenerateContext } from './types' const cwd = process.cwd() export function createGenerateContext(): GenerateContext { const context: GenerateContext = { rootPath: cwd, templatePath: '', } handleTemplatePath(context) return context } function handleTemplatePath(context: GenerateContext) { let templatePath if (extname(process.argv[1]) === '.ts') templatePath = resolve(process.cwd(), 'templates') else templatePath = resolve(__dirname, '../templates') context.templatePath = templatePath }