@@ -5,6 +5,7 @@ import Poller from '../utils/poller';
55import Config from '../utils/config' ;
66import Tunnel from '../utils/tunnel' ;
77import ora from 'ora' ;
8+ import chalk from 'chalk' ;
89
910interface Arguments {
1011 [ x : string ] : unknown ;
@@ -16,24 +17,28 @@ export default class RunProject {
1617 private uploader : Uploader | undefined = undefined ;
1718 private poller : Poller | undefined = undefined ;
1819 private tunnel : Tunnel | undefined = undefined ;
20+ private configFilePath : string | undefined = undefined ;
1921
2022 constructor ( argv : Arguments ) {
21- try {
22- this . start ( ) ;
23- } catch ( e ) {
24- console . log ( 'error' , e )
25- log . error ( e )
23+ if ( typeof ( argv . cf ) === 'string' ) {
24+ this . configFilePath = argv . cf ;
2625 }
2726 }
2827
2928 public async start ( ) : Promise < void > {
30- const config = await Config . getConfig ( ) ;
29+ let config ;
30+ try {
31+ config = await Config . getConfig ( this . configFilePath || `testingbot.json` ) ;
32+ } catch ( e ) {
33+ console . error ( chalk . white . bgRed . bold ( `Configuration file problem: ${ e . message } for Config File: ${ this . configFilePath || `testingbot.json` } ` ) ) ;
34+ return ;
35+ }
36+
3137 const configValidationErrors = Config . validate ( config ) ;
3238
3339 if ( configValidationErrors . length > 0 ) {
34- throw new Error (
35- `Configuration errors: ${ configValidationErrors . join ( '\n' ) } ` ,
36- ) ;
40+ console . error ( chalk . white . bgRed . bold ( `Configuration errors: ${ configValidationErrors . join ( '\n' ) } ` ) ) ;
41+ return ;
3742 }
3843
3944 this . archiver = new Archiver ( config ) ;
@@ -44,7 +49,8 @@ export default class RunProject {
4449 let zipFile : string ;
4550
4651 if ( ! this . archiver || ! this . uploader ) {
47- throw new Error ( `Invalid state, please try again` ) ;
52+ console . error ( chalk . white . bgRed . bold ( `Invalid state, please try again` ) ) ;
53+ return ;
4854 }
4955
5056 if ( config . run_settings . start_tunnel ) {
@@ -53,24 +59,23 @@ export default class RunProject {
5359 tunnelSpinner . succeed ( 'TestingBot Tunnel Ready' ) ;
5460 }
5561
62+ const uploadSpinner = ora ( 'Starting Project on TestingBot' ) . start ( ) ;
5663 try {
5764 zipFile = await this . archiver . start ( ) ;
5865 } catch ( err ) {
59- log . error ( err ) ;
66+ console . error ( err ) ;
6067 return ;
6168 }
6269
6370 try {
64- const uploadSpinner = ora ( 'Starting Project on TestingBot' ) . start ( ) ;
65-
6671 const response = await this . uploader . start ( zipFile ) ;
6772 uploadSpinner . succeed ( 'Cypress is now running on TestingBot' )
6873
69- const poller = await this . poller . check ( response . id )
74+ const poller = await this . poller . check ( response . id , uploadSpinner )
7075 log . info ( poller )
7176
7277 } catch ( err ) {
73- log . error ( err ) ;
78+ console . error ( chalk . white . bgRed . bold ( err ) ) ;
7479 if ( config . run_settings . start_tunnel ) {
7580 await this . tunnel . stop ( ) ;
7681 }
0 commit comments