@@ -965,11 +965,25 @@ function handleConfigListCommand(argv: any) {
965965function handleConfigSetCommand ( argv : any ) {
966966 const parseSetting = ( ) : { key : string ; value : string } => {
967967 if ( argv . _ . length !== 3 ) {
968- console . error ( `Invalid setting. Use "set settingKey value" format.` ) ;
968+ console . error ( `Invalid setting. Use "set < settingKey> < value> " format.` ) ;
969969 return { key : undefined , value : undefined } ;
970970 }
971971
972- return { key : argv . _ [ 1 ] , value : JSON . parse ( argv . _ [ 2 ] ) } ;
972+ let value ;
973+
974+ // boolean, arrays, objects
975+ try {
976+ value = JSON . parse ( argv . _ [ 2 ] ) ;
977+ } catch ( error ) {
978+ try {
979+ // string without quotes
980+ value = JSON . parse ( `"${ argv . _ [ 2 ] } "` ) ;
981+ } catch ( error ) {
982+ console . error ( error . message ) ;
983+ }
984+ }
985+
986+ return { key : argv . _ [ 1 ] , value : value } ;
973987 } ;
974988
975989 let projectPath = '' ;
@@ -981,7 +995,7 @@ function handleConfigSetCommand(argv: any) {
981995 : process . cwd ( ) ;
982996 if (
983997 argv . projectPath &&
984- ! ( fs . existsSync ( projectPath ) && fs . statSync ( projectPath ) . isFile ( ) )
998+ ! ( fs . existsSync ( projectPath ) && fs . statSync ( projectPath ) . isDirectory ( ) )
985999 ) {
9861000 console . error ( `Invalid project path! "${ projectPath } "` ) ;
9871001 return ;
@@ -1000,7 +1014,8 @@ function handleConfigSetCommand(argv: any) {
10001014 return ;
10011015 }
10021016
1003- if ( ! ( key && value ) ) {
1017+ if ( key === undefined || value === undefined ) {
1018+ console . error ( 'Failed to parse key value pair!' ) ;
10041019 return ;
10051020 }
10061021
@@ -1034,7 +1049,7 @@ function handleConfigSetCommand(argv: any) {
10341049function handleConfigUnsetCommand ( argv : any ) {
10351050 const parseKey = ( ) : string => {
10361051 if ( argv . _ . length !== 2 ) {
1037- console . error ( `Invalid setting. Use "set settingKey value " format.` ) ;
1052+ console . error ( `Invalid setting. Use "unset < settingKey> " format.` ) ;
10381053 return undefined ;
10391054 }
10401055
@@ -1050,7 +1065,7 @@ function handleConfigUnsetCommand(argv: any) {
10501065 : process . cwd ( ) ;
10511066 if (
10521067 argv . projectPath &&
1053- ! ( fs . existsSync ( projectPath ) && fs . statSync ( projectPath ) . isFile ( ) )
1068+ ! ( fs . existsSync ( projectPath ) && fs . statSync ( projectPath ) . isDirectory ( ) )
10541069 ) {
10551070 console . error ( `Invalid project path! "${ projectPath } "` ) ;
10561071 return ;
0 commit comments