1
- const fs = require ( 'fs/promises' )
2
- const fs_constants = require ( 'fs' ) . constants
3
- // eslint-disable-next-line n/no-unpublished-require
4
- const wget = require ( 'wget-improved' )
1
+ import { mkdir , access , constants } from 'fs/promises'
2
+ import { exit } from 'process'
3
+ import wget from 'wget-improved'
5
4
6
5
async function get ( url , path ) {
7
6
let totalBytes = 0
@@ -23,25 +22,25 @@ async function get(url, path) {
23
22
}
24
23
} )
25
24
download . on ( 'end' , function ( output ) {
26
- process . stdout . write ( `Downloaded 100% of ' ${ path } '. Total length ${ totalBytes } bytes.\n` )
25
+ process . stdout . write ( `${ output } , total length ${ totalBytes } bytes.\n` )
27
26
resolve ( output )
28
27
} )
29
28
} )
30
29
}
31
30
32
31
async function checkInstall ( ) {
33
32
console . log ( 'Checking/Installing swagger codegen.' )
34
- await fs . mkdir ( 'jars' ) . catch ( ( e ) => {
33
+ await mkdir ( 'jars' ) . catch ( ( e ) => {
35
34
if ( e . code === 'EEXIST' ) return
36
35
else throw e
37
36
} )
38
37
39
38
const srcPath =
40
- 'https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.34 /swagger-codegen-cli-3.0.34 .jar'
39
+ 'https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.68 /swagger-codegen-cli-3.0.68 .jar'
41
40
const swaggerFilename = 'swagger-codegen-cli.jar'
42
- await fs
43
- . access ( `jars/${ swaggerFilename } ` , fs_constants . R_OK )
44
- . catch ( async ( ) => get ( srcPath , `jars/${ swaggerFilename } ` ) )
41
+ await access ( `jars/${ swaggerFilename } ` , constants . R_OK ) . catch ( async ( ) => get ( srcPath , `jars/${ swaggerFilename } ` ) )
45
42
}
46
43
47
- checkInstall ( )
44
+ await checkInstall ( )
45
+
46
+ exit ( 0 )
0 commit comments