@@ -103,21 +103,23 @@ export default class AddCommand extends Command {
103103      }  catch  ( error )  { 
104104        // we cannot ask user to do prompt in test environment 
105105        if  ( process . env . NODE_ENV  !==  'test' )  { 
106-           const  {  abi : abiFile  }  =  await  prompt . ask < {  abi : string  } > ( [ 
107-             { 
108-               type : 'input' , 
109-               name : 'abi' , 
110-               message : 'ABI file (path)' , 
111-               validate : async  ( value : string )  =>  { 
112-                 try  { 
113-                   EthereumABI . load ( contractName ,  value ) ; 
114-                   return  true ; 
115-                 }  catch  ( e )  { 
116-                   return  `Failed to load ABI from ${ value } ${ e . message }  ; 
117-                 } 
106+           const  {  abi : abiFile  }  =  await  prompt 
107+             . ask < {  abi : string  } > ( [ 
108+               { 
109+                 type : 'input' , 
110+                 name : 'abi' , 
111+                 message : 'ABI file (path)' , 
112+                 validate : async  ( value : string )  =>  { 
113+                   try  { 
114+                     EthereumABI . load ( contractName ,  value ) ; 
115+                     return  true ; 
116+                   }  catch  ( e )  { 
117+                     return  `Failed to load ABI from ${ value } ${ e . message }  ; 
118+                   } 
119+                 } , 
118120              } , 
119-             } , 
120-           ] ) ; 
121+             ] ) 
122+              . catch ( ( )   =>   this . exit ( 1 ) ) ;   // properly handle ESC 
121123          ethabi  =  EthereumABI . load ( contractName ,  abiFile ) ; 
122124        } 
123125      } 
@@ -130,18 +132,20 @@ export default class AddCommand extends Command {
130132      // we cannot ask user to do prompt in test environment 
131133      if  ( process . env . NODE_ENV  !==  'test' )  { 
132134        // If we can't get the start block, we'll just leave it out of the manifest 
133-         const  {  startBlock : userInputStartBlock  }  =  await  prompt . ask < {  startBlock : string  } > ( [ 
134-           { 
135-             type : 'input' , 
136-             name : 'startBlock' , 
137-             message : 'Start Block' , 
138-             initial : '0' , 
139-             validate : value  =>  parseInt ( value )  >=  0 , 
140-             result ( value )  { 
141-               return  value ; 
135+         const  {  startBlock : userInputStartBlock  }  =  await  prompt 
136+           . ask < {  startBlock : string  } > ( [ 
137+             { 
138+               type : 'input' , 
139+               name : 'startBlock' , 
140+               message : 'Start Block' , 
141+               initial : '0' , 
142+               validate : value  =>  parseInt ( value )  >=  0 , 
143+               result ( value )  { 
144+                 return  value ; 
145+               } , 
142146            } , 
143-           } , 
144-         ] ) ; 
147+           ] ) 
148+            . catch ( ( )   =>   this . exit ( 1 ) ) ; 
145149        startBlock  =  userInputStartBlock ; 
146150      } 
147151    } 
@@ -155,18 +159,20 @@ export default class AddCommand extends Command {
155159    }  catch  ( error )  { 
156160      // not asking user to do prompt in test environment 
157161      if  ( process . env . NODE_ENV  !==  'test' )  { 
158-         const  {  contractName : userInputContractName  }  =  await  prompt . ask < {  contractName : string  } > ( [ 
159-           { 
160-             type : 'input' , 
161-             name : 'contractName' , 
162-             message : 'Contract Name' , 
163-             initial : 'Contract' , 
164-             validate : value  =>  value  &&  value . length  >  0 , 
165-             result ( value )  { 
166-               return  value ; 
162+         const  {  contractName : userInputContractName  }  =  await  prompt 
163+           . ask < {  contractName : string  } > ( [ 
164+             { 
165+               type : 'input' , 
166+               name : 'contractName' , 
167+               message : 'Contract Name' , 
168+               initial : 'Contract' , 
169+               validate : value  =>  value  &&  value . length  >  0 , 
170+               result ( value )  { 
171+                 return  value ; 
172+               } , 
167173            } , 
168-           } , 
169-         ] ) ; 
174+           ] ) 
175+            . catch ( ( )   =>   this . exit ( 1 ) ) ; 
170176        contractName  =  userInputContractName ; 
171177      } 
172178    } 
0 commit comments