@@ -33,12 +33,12 @@ function validateProjectToken(options) {
3333 } else {
3434 console . log ( '[smartui] Project Token not validated. Error: ' , error . message ) ;
3535 }
36- process . exit ( 0 ) ;
36+ process . exit ( constants . ERROR_CATCHALL ) ;
3737 } ) ;
3838 }
3939 else {
4040 console . log ( '[smartui] Error: No PROJECT_TOKEN set' ) ;
41- process . exit ( 0 ) ;
41+ process . exit ( constants . ERROR_CATCHALL ) ;
4242 }
4343} ;
4444
@@ -48,7 +48,7 @@ function validateStorybookUrl(url) {
4848 aboutUrl = new URL ( '?path=/settings/about' , url ) . href ;
4949 } catch ( error ) {
5050 console . log ( '[smartui] Error: ' , error . message )
51- process . exit ( 0 ) ;
51+ process . exit ( constants . ERROR_CATCHALL ) ;
5252 }
5353 return axios . get ( aboutUrl )
5454 . then ( function ( response ) {
@@ -62,24 +62,24 @@ function validateStorybookUrl(url) {
6262 } else {
6363 console . log ( '[smartui] Connection to storybook not established. Error: ' , error . message ) ;
6464 }
65- process . exit ( 0 ) ;
65+ process . exit ( constants . ERROR_CATCHALL ) ;
6666 } ) ;
6767} ;
6868
6969async function validateStorybookDir ( dir ) {
7070 // verify the directory exists
7171 if ( ! fs . existsSync ( dir ) ) {
7272 console . log ( `[smartui] Error: No directory found: ${ dir } ` ) ;
73- process . exit ( 1 ) ;
73+ process . exit ( constants . ERROR_CATCHALL ) ;
7474 }
7575 // Verify project.json and stories.json exist to confirm it's a storybook-static dir
7676 if ( ! fs . existsSync ( dir + '/index.html' ) ) {
7777 console . log ( `[smartui] Given directory is not a storybook static directory. Error: No index.html found` ) ;
78- process . exit ( 1 ) ;
78+ process . exit ( constants . ERROR_CATCHALL ) ;
7979 }
8080 if ( ! fs . existsSync ( dir + '/stories.json' ) ) {
8181 console . log ( `[smartui] Given directory is not a storybook static directory. Error: No stories.json found` ) ;
82- process . exit ( 1 ) ;
82+ process . exit ( constants . ERROR_CATCHALL ) ;
8383 }
8484} ;
8585
@@ -97,21 +97,21 @@ async function validateLatestBuild(options) {
9797 if ( response . data . status === 'Failure' ) {
9898 console . log ( `[smartui] Build with commit '${ commit . shortHash } ' on branch '${ commit . branch } ' already exists.` ) ;
9999 console . log ( '[smartui] Use option --force-rebuild to forcefully push a new build.' ) ;
100- process . exit ( 0 ) ;
100+ process . exit ( constants . ERROR_BUILD_ALREADY_EXISTS ) ;
101101 }
102102 } )
103103 . catch ( function ( error ) {
104104 // TODO: Add retries
105105 console . log ( '[smartui] Cannot fetch latest build of the project. Error: ' , error . message ) ;
106- process . exit ( 1 ) ;
106+ process . exit ( constants . ERROR_CATCHALL ) ;
107107 } ) ;
108108}
109109
110110function validateConfig ( configFile ) {
111111 // Verify config file exists
112112 if ( ! fs . existsSync ( configFile ) ) {
113113 console . log ( `[smartui] Error: Config file ${ configFile } not found.` ) ;
114- process . exit ( 1 ) ;
114+ process . exit ( constants . ERROR_CATCHALL ) ;
115115 }
116116
117117 // Parse JSON
@@ -120,15 +120,15 @@ function validateConfig(configFile) {
120120 storybookConfig = JSON . parse ( fs . readFileSync ( configFile ) ) . storybook ;
121121 } catch ( error ) {
122122 console . log ( '[smartui] Error: ' , error . message ) ;
123- process . exit ( 1 ) ;
123+ process . exit ( constants . ERROR_CATCHALL ) ;
124124 }
125125
126126 try {
127127 validateConfigBrowsers ( storybookConfig . browsers ) ;
128128 storybookConfig . resolutions = validateConfigResolutions ( storybookConfig . resolutions ) ;
129129 } catch ( error ) {
130130 console . log ( `[smartui] Error: Invalid config, ${ error . message } ` ) ;
131- process . exit ( 0 ) ;
131+ process . exit ( constants . ERROR_CATCHALL ) ;
132132 }
133133
134134 // Sanity check waitForTimeout
0 commit comments