@@ -25,9 +25,8 @@ export default class SecurityBlog extends SecurityRelease {
2525 const content = this . readVulnerabilitiesJSON ( ) ;
2626 // validate the release date read from vulnerabilities JSON
2727 if ( ! content . releaseDate ) {
28- cli . error ( 'Release date is not set in vulnerabilities.json,' +
28+ throw new Error ( 'Release date is not set in vulnerabilities.json,' +
2929 ' run `git node security --update-date=YYYY/MM/DD` to set the release date.' ) ;
30- process . exit ( 1 ) ;
3130 }
3231
3332 validateDate ( content . releaseDate ) ;
@@ -109,9 +108,8 @@ export default class SecurityBlog extends SecurityRelease {
109108 // read vulnerabilities JSON file
110109 const content = this . readVulnerabilitiesJSON ( ) ;
111110 if ( ! content . releaseDate ) {
112- cli . error ( 'Release date is not set in vulnerabilities.json,' +
111+ throw new Error ( 'Release date is not set in vulnerabilities.json,' +
113112 ' run `git node security --update-date=YYYY/MM/DD` to set the release date.' ) ;
114- process . exit ( 1 ) ;
115113 }
116114
117115 validateDate ( content . releaseDate ) ;
@@ -133,8 +131,7 @@ export default class SecurityBlog extends SecurityRelease {
133131 const preReleasePath = path . resolve ( pathToBlogPosts , data . slug + '.md' ) ;
134132 let preReleaseContent = this . findExistingPreRelease ( preReleasePath ) ;
135133 if ( ! preReleaseContent ) {
136- cli . error ( `Existing pre-release not found! Path: ${ preReleasePath } ` ) ;
137- process . exit ( 1 ) ;
134+ throw new Error ( `Existing pre-release not found! Path: ${ preReleasePath } ` ) ;
138135 }
139136
140137 const postReleaseContent = await this . buildPostRelease ( template , data , content ) ;
@@ -247,23 +244,20 @@ export default class SecurityBlog extends SecurityRelease {
247244 for ( const report of reports ) {
248245 const cveId = report . cveIds ?. join ( ', ' ) ;
249246 if ( ! cveId ) {
250- this . cli . error ( `CVE ID for vulnerability ${ report . link } ${ report . title } not found` ) ;
251- process . exit ( 1 ) ;
247+ throw new Error ( `CVE ID for vulnerability ${ report . link } ${ report . title } not found` ) ;
252248 }
253249 template += `## ${ report . title } (${ cveId } ) - (${ report . severity . rating } )\n\n` ;
254250 if ( ! report . summary ) {
255- this . cli . error ( `Summary missing for vulnerability ${ report . link } ` +
251+ throw new Error ( `Summary missing for vulnerability ${ report . link } ` +
256252 `${ report . title } . Please create it before continuing.` ) ;
257- process . exit ( 1 ) ;
258253 }
259254
260255 template += `${ report . summary } \n\n` ;
261256 const releaseLines = report . affectedVersions . join ( ', ' ) ;
262257 template += `Impact:\n\n- This vulnerability affects all users\
263258 in active release lines: ${ releaseLines } \n\n` ;
264259 if ( ! report . patchAuthors ) {
265- this . cli . error ( `Missing patch author for vulnerability ${ report . link } ${ report . title } ` ) ;
266- process . exit ( 1 ) ;
260+ throw new Error ( `Missing patch author for vulnerability ${ report . link } ${ report . title } ` ) ;
267261 }
268262 template += `Thank you, to ${ report . reporter } for reporting this vulnerability\
269263 and thank you ${ report . patchAuthors . join ( ' and ' ) } for fixing it.\n\n` ;
@@ -324,8 +318,7 @@ export default class SecurityBlog extends SecurityRelease {
324318 const impact = new Map ( ) ;
325319 for ( const report of content . reports ) {
326320 if ( ! report . severity ?. rating ) {
327- this . cli . error ( `severity.rating not found for report ${ report . id } .` ) ;
328- process . exit ( 1 ) ;
321+ throw new Error ( `severity.rating not found for report ${ report . id } .` ) ;
329322 }
330323
331324 for ( const version of report . affectedVersions ) {
@@ -348,8 +341,7 @@ export default class SecurityBlog extends SecurityRelease {
348341
349342 for ( const report of content . reports ) {
350343 if ( ! report . severity ?. rating ) {
351- this . cli . error ( `severity.rating not found for report ${ report . id } .` ) ;
352- process . exit ( 1 ) ;
344+ throw new Error ( `severity.rating not found for report ${ report . id } .` ) ;
353345 }
354346
355347 const rating = report . severity . rating ;
@@ -367,8 +359,7 @@ export default class SecurityBlog extends SecurityRelease {
367359 getPreReleaseVulnerabilities ( content ) {
368360 for ( const report of content . reports ) {
369361 if ( ! report . severity ?. rating ) {
370- this . cli . error ( `severity.rating not found for report ${ report . id } .` ) ;
371- process . exit ( 1 ) ;
362+ throw new Error ( `severity.rating not found for report ${ report . id } .` ) ;
372363 }
373364 }
374365
0 commit comments