-
Notifications
You must be signed in to change notification settings - Fork 121
/
index.js
executable file
·48 lines (40 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env node
/* eslint-disable max-len */
const argv = require('yargs/yargs')(process.argv.slice(2))
.usage('Usage: $0 [options]')
.options({
validate: {
description:
'Check the proxy.config.json file in the current working directory for validation errors.',
required: false,
alias: 'v',
},
config: {
description: 'Path to custom git-proxy configuration file.',
default: 'proxy.config.json',
required: false,
alias: 'c',
},
})
.strict().argv;
const config = require('./src/config/file');
config.configFile = argv.c ? argv.c : undefined;
if (argv.v) {
const fs = require('fs');
if (!fs.existsSync(config.configFile)) {
console.error(
`Config file ${config.configFile} doesn't exist, nothing to validate! Did you forget -c/--config?`,
);
process.exit(1);
}
config.validate();
console.log(`${config.configFile} is valid`);
process.exit(0);
}
config.validate();
const proxy = require('./src/proxy');
const service = require('./src/service');
proxy.start();
service.start();
module.exports.proxy = proxy;
module.exports.service = service;