@@ -33,12 +33,12 @@ function validateProjectToken(options) {
33
33
} else {
34
34
console . log ( '[smartui] Project Token not validated. Error: ' , error . message ) ;
35
35
}
36
- process . exit ( 0 ) ;
36
+ process . exit ( constants . ERROR_CATCHALL ) ;
37
37
} ) ;
38
38
}
39
39
else {
40
40
console . log ( '[smartui] Error: No PROJECT_TOKEN set' ) ;
41
- process . exit ( 0 ) ;
41
+ process . exit ( constants . ERROR_CATCHALL ) ;
42
42
}
43
43
} ;
44
44
@@ -48,7 +48,7 @@ function validateStorybookUrl(url) {
48
48
aboutUrl = new URL ( '?path=/settings/about' , url ) . href ;
49
49
} catch ( error ) {
50
50
console . log ( '[smartui] Error: ' , error . message )
51
- process . exit ( 0 ) ;
51
+ process . exit ( constants . ERROR_CATCHALL ) ;
52
52
}
53
53
return axios . get ( aboutUrl )
54
54
. then ( function ( response ) {
@@ -62,24 +62,24 @@ function validateStorybookUrl(url) {
62
62
} else {
63
63
console . log ( '[smartui] Connection to storybook not established. Error: ' , error . message ) ;
64
64
}
65
- process . exit ( 0 ) ;
65
+ process . exit ( constants . ERROR_CATCHALL ) ;
66
66
} ) ;
67
67
} ;
68
68
69
69
async function validateStorybookDir ( dir ) {
70
70
// verify the directory exists
71
71
if ( ! fs . existsSync ( dir ) ) {
72
72
console . log ( `[smartui] Error: No directory found: ${ dir } ` ) ;
73
- process . exit ( 1 ) ;
73
+ process . exit ( constants . ERROR_CATCHALL ) ;
74
74
}
75
75
// Verify project.json and stories.json exist to confirm it's a storybook-static dir
76
76
if ( ! fs . existsSync ( dir + '/index.html' ) ) {
77
77
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 ) ;
79
79
}
80
80
if ( ! fs . existsSync ( dir + '/stories.json' ) ) {
81
81
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 ) ;
83
83
}
84
84
} ;
85
85
@@ -97,21 +97,21 @@ async function validateLatestBuild(options) {
97
97
if ( response . data . status === 'Failure' ) {
98
98
console . log ( `[smartui] Build with commit '${ commit . shortHash } ' on branch '${ commit . branch } ' already exists.` ) ;
99
99
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 ) ;
101
101
}
102
102
} )
103
103
. catch ( function ( error ) {
104
104
// TODO: Add retries
105
105
console . log ( '[smartui] Cannot fetch latest build of the project. Error: ' , error . message ) ;
106
- process . exit ( 1 ) ;
106
+ process . exit ( constants . ERROR_CATCHALL ) ;
107
107
} ) ;
108
108
}
109
109
110
110
function validateConfig ( configFile ) {
111
111
// Verify config file exists
112
112
if ( ! fs . existsSync ( configFile ) ) {
113
113
console . log ( `[smartui] Error: Config file ${ configFile } not found.` ) ;
114
- process . exit ( 1 ) ;
114
+ process . exit ( constants . ERROR_CATCHALL ) ;
115
115
}
116
116
117
117
// Parse JSON
@@ -120,15 +120,15 @@ function validateConfig(configFile) {
120
120
storybookConfig = JSON . parse ( fs . readFileSync ( configFile ) ) . storybook ;
121
121
} catch ( error ) {
122
122
console . log ( '[smartui] Error: ' , error . message ) ;
123
- process . exit ( 1 ) ;
123
+ process . exit ( constants . ERROR_CATCHALL ) ;
124
124
}
125
125
126
126
try {
127
127
validateConfigBrowsers ( storybookConfig . browsers ) ;
128
128
storybookConfig . resolutions = validateConfigResolutions ( storybookConfig . resolutions ) ;
129
129
} catch ( error ) {
130
130
console . log ( `[smartui] Error: Invalid config, ${ error . message } ` ) ;
131
- process . exit ( 0 ) ;
131
+ process . exit ( constants . ERROR_CATCHALL ) ;
132
132
}
133
133
134
134
// Sanity check waitForTimeout
0 commit comments