diff options
author | 2021-03-16 12:37:45 -0600 | |
---|---|---|
committer | 2021-03-16 12:37:45 -0600 | |
commit | 8c45c4a8567e31a10ae954fa11a0f3f1f94fd89c (patch) | |
tree | e526f67e93ed5a7fcf9237c2d30ec536a4a96d7b /src/cli.ts | |
parent | 1f5c7c791fe3595f4c775192ffc6b6a15efb71a1 (diff) | |
download | astro-8c45c4a8567e31a10ae954fa11a0f3f1f94fd89c.tar.gz astro-8c45c4a8567e31a10ae954fa11a0f3f1f94fd89c.tar.zst astro-8c45c4a8567e31a10ae954fa11a0f3f1f94fd89c.zip |
Annoying Lint PR™ (#3)
* Add Prettier + ESLint
* Format files
Diffstat (limited to 'src/cli.ts')
-rw-r--r-- | src/cli.ts | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/cli.ts b/src/cli.ts index e2ff727bd..62e50f3eb 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -14,17 +14,20 @@ type Arguments = yargs.Arguments; type cliState = 'help' | 'version' | 'dev' | 'build'; function resolveArgs(flags: Arguments): cliState { - if(flags.version) { + if (flags.version) { return 'version'; - } else if(flags.help) { + } else if (flags.help) { return 'help'; } const cmd = flags._[2]; - switch(cmd) { - case 'dev': return 'dev'; - case 'build': return 'build'; - default: return 'help'; + switch (cmd) { + case 'dev': + return 'dev'; + case 'build': + return 'build'; + default: + return 'help'; } } @@ -47,7 +50,7 @@ async function printVersion() { } async function loadConfig(rawRoot: string | undefined): Promise<AstroConfig | undefined> { - if(typeof rawRoot === 'undefined') { + if (typeof rawRoot === 'undefined') { rawRoot = process.cwd(); } @@ -55,7 +58,7 @@ async function loadConfig(rawRoot: string | undefined): Promise<AstroConfig | un const fileProtocolRoot = `file://${root}/`; const astroConfigPath = pathJoin(root, 'astro.config.mjs'); - if(!existsSync(astroConfigPath)) { + if (!existsSync(astroConfigPath)) { return undefined; } @@ -67,7 +70,7 @@ async function loadConfig(rawRoot: string | undefined): Promise<AstroConfig | un async function runCommand(rawRoot: string, cmd: (a: AstroConfig) => Promise<void>) { const astroConfig = await loadConfig(rawRoot); - if(typeof astroConfig === 'undefined') { + if (typeof astroConfig === 'undefined') { console.error(colors.red(' An astro.config.mjs file is required.\n')); printHelp(); process.exit(1); @@ -78,14 +81,14 @@ async function runCommand(rawRoot: string, cmd: (a: AstroConfig) => Promise<void const cmdMap = new Map([ ['build', generate], - ['dev', devServer] + ['dev', devServer], ]); export async function cli(args: string[]) { const flags = yargs(args); const state = resolveArgs(flags); - switch(state) { + switch (state) { case 'help': { printHelp(); process.exit(1); @@ -102,4 +105,4 @@ export async function cli(args: string[]) { runCommand(flags._[3], cmd); } } -}
\ No newline at end of file +} |