diff options
Diffstat (limited to 'packages/create-astro/src/index.tsx')
-rw-r--r-- | packages/create-astro/src/index.tsx | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/packages/create-astro/src/index.tsx b/packages/create-astro/src/index.tsx index 0927eaae9..9a510d7b7 100644 --- a/packages/create-astro/src/index.tsx +++ b/packages/create-astro/src/index.tsx @@ -3,7 +3,7 @@ import React from 'react'; import App from './components/App'; import Version from './components/Version'; import Exit from './components/Exit'; -import {render} from 'ink'; +import { render } from 'ink'; import { getTemplates, addProcessListeners } from './utils'; import { args as argsConfig } from './config'; import arg from 'arg'; @@ -11,36 +11,36 @@ import Help from './components/Help'; /** main `create-astro` CLI */ export default async function createAstro() { - const args = arg(argsConfig); - const projectName = args._[0]; - if (args['--version']) { - return render(<Version />); - } - const templates = await getTemplates(); - if (args['--help']) { - return render(<Help context={{ templates }} />) - } + const args = arg(argsConfig); + const projectName = args._[0]; + if (args['--version']) { + return render(<Version />); + } + const templates = await getTemplates(); + if (args['--help']) { + return render(<Help context={{ templates }} />); + } - const pkgManager = /yarn/.test(process.env.npm_execpath) ? 'yarn' : 'npm'; - const use = (args['--use'] ?? pkgManager) as 'npm'|'yarn'; - const template = args['--template']; - const force = args['--force']; - const run = args['--run'] ?? true; - - const app = render(<App context={{ projectName, template, templates, force, run, use }} />); + const pkgManager = /yarn/.test(process.env.npm_execpath) ? 'yarn' : 'npm'; + const use = (args['--use'] ?? pkgManager) as 'npm' | 'yarn'; + const template = args['--template']; + const force = args['--force']; + const run = args['--run'] ?? true; - const onError = () => { - if (app) app.clear(); - render(<Exit didError />); - } - const onExit = () => { - if (app) app.clear(); - render(<Exit />); - } - addProcessListeners([ - ['uncaughtException', onError], - ['exit', onExit], - ['SIGINT', onExit], - ['SIGTERM', onExit], - ]) + const app = render(<App context={{ projectName, template, templates, force, run, use }} />); + + const onError = () => { + if (app) app.clear(); + render(<Exit didError />); + }; + const onExit = () => { + if (app) app.clear(); + render(<Exit />); + }; + addProcessListeners([ + ['uncaughtException', onError], + ['exit', onExit], + ['SIGINT', onExit], + ['SIGTERM', onExit], + ]); } |