@@ -16,40 +16,39 @@ let { packageFiles, registerExitHandler } = require('./helpers');
1616
1717registerExitHandler ( ) ;
1818
19- let exitCode = 0 ;
20-
2119// First 2 arguments are node and script name skip them
2220// Check if rest has --fix
2321const fix = process . argv . slice ( 2 ) . includes ( '--fix' ) ;
2422
2523const envAssignment = shell . env [ 'ASSIGNMENT' ] ;
26- if ( envAssignment ) {
24+ if ( envAssignment ) {
2725 packageFiles = [ `exercises/${ envAssignment } /package.json` ] ;
2826}
2927
3028// Check if package name in each exercises' package.json is of the format "@exercism/javascript-<exercise>"
31- packageFiles . forEach ( filePath => {
29+ packageFiles . forEach ( ( filePath ) => {
3230 const file = JSON . parse ( shell . cat ( filePath ) . toString ( ) ) ;
3331
3432 const givenName = file [ 'name' ] ;
3533 const exerciseName = filePath . split ( '/' ) [ 2 ] ;
3634 const expectedName = `@exercism/javascript-${ exerciseName } ` ;
3735
38- if ( givenName == expectedName ) {
36+ if ( givenName = == expectedName ) {
3937 shell . echo ( `[Success]: Package name ${ givenName } is in correct format` ) ;
4038 return ;
4139 }
4240
43- if ( fix ) {
41+ if ( fix ) {
4442 file [ 'name' ] = expectedName ;
45- const fileWithFixedName = new shell . ShellString ( JSON . stringify ( file , undefined , 2 ) + '\n' ) ;
43+ const fileWithFixedName = new shell . ShellString (
44+ JSON . stringify ( file , undefined , 2 ) + '\n'
45+ ) ;
4646 fileWithFixedName . to ( filePath ) ;
4747 shell . echo ( `[Success]: Fixed package name in ${ filePath } ` ) ;
48- }
49- else {
50- exitCode = 1 ;
51- shell . echo ( `[Failure]: Package name in ${ filePath } must be ${ expectedName } "` ) ;
48+ } else {
49+ shell . echo (
50+ `[Failure]: Package name in ${ filePath } must be ${ expectedName } "`
51+ ) ;
52+ shell . exit ( 1 ) ;
5253 }
5354} ) ;
54-
55- shell . exit ( exitCode ) ;
0 commit comments