1
1
#!/usr/bin/env node
2
2
/* eslint-disable max-len */
3
- const argv = require ( 'yargs/yargs' ) ( process . argv . slice ( 2 ) )
3
+ import yargs from 'yargs' ;
4
+ import { hideBin } from 'yargs/helpers' ;
5
+ import * as fs from 'fs' ;
6
+ import config from './src/config/file' ;
7
+ import proxy from './src/proxy' ;
8
+ import service from './src/service' ;
9
+
10
+ const argv = yargs ( hideBin ( process . argv ) )
4
11
. usage ( 'Usage: $0 [options]' )
5
12
. options ( {
6
13
validate : {
7
14
description :
8
15
'Check the proxy.config.json file in the current working directory for validation errors.' ,
9
16
required : false ,
10
17
alias : 'v' ,
18
+ type : 'boolean' ,
11
19
} ,
12
20
config : {
13
21
description : 'Path to custom git-proxy configuration file.' ,
14
22
default : 'proxy.config.json' ,
15
23
required : false ,
16
24
alias : 'c' ,
25
+ type : 'string' ,
17
26
} ,
18
27
} )
19
- . strict ( ) . argv ;
28
+ . strict ( )
29
+ . parseSync ( ) ;
20
30
21
- const config = require ( './src/config/file' ) ;
22
31
config . configFile = argv . c ? argv . c : undefined ;
23
32
24
33
if ( argv . v ) {
25
- const fs = require ( 'fs' ) ;
26
-
27
- if ( ! fs . existsSync ( config . configFile ) ) {
34
+ if ( ! fs . existsSync ( config . configFile as string ) ) {
28
35
console . error (
29
36
`Config file ${ config . configFile } doesn't exist, nothing to validate! Did you forget -c/--config?` ,
30
37
) ;
@@ -38,11 +45,7 @@ if (argv.v) {
38
45
39
46
config . validate ( ) ;
40
47
41
- const proxy = require ( './src/proxy' ) ;
42
- const service = require ( './src/service' ) ;
43
-
44
48
proxy . start ( ) ;
45
49
service . start ( ) ;
46
50
47
- module . exports . proxy = proxy ;
48
- module . exports . service = service ;
51
+ export { proxy , service } ;
0 commit comments