File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import fs from 'fs';
33import path from 'path' ;
44import { serve , build , init } from './main' ;
55import chalk from 'chalk' ;
6+ import { printError } from './utils' ;
67import { version } from '../package.json' ;
78
89yargs . usage (
@@ -138,17 +139,18 @@ export const createCommands = (yargs) => {
138139 } ,
139140 } )
140141 . recommendCommands ( )
142+ . strict ( )
141143}
142144
143- export const argsToOpts = ( ) => {
144- const { argv } = createCommands ( yargs ) ;
145- const result = { ...argv } ;
146- delete result . $0 ;
147-
148- return result ;
145+ export const argsToOpts = async ( ) => {
146+ return await createCommands ( yargs ) . parse ( ) ;
149147} ;
150148
151- export default ( opts = { } ) => {
152- let options = argsToOpts ( ) ;
153- if ( ! options . _ . length ) yargs . showHelp ( ) ;
149+ export default async ( opts = { } ) => {
150+ try {
151+ let options = await argsToOpts ( ) ;
152+ if ( ! options . _ . length ) yargs . showHelp ( ) ;
153+ } catch ( error ) {
154+ printError ( ( error . stack || error ) . toString ( ) )
155+ }
154156}
You can’t perform that action at this time.
0 commit comments