-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathworker.js
43 lines (38 loc) · 1.14 KB
/
worker.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
/* eslint-disable no-console */
const envfile = require('envfile');
const fs = require('fs');
const prompts = require('prompts');
const { program } = require('commander');
const Worker = require('./src');
const { version } = require('./package.json');
program.version(version);
async function setup() {
const questions = [
{
type: 'text',
name: 'transferEncryptToken',
message: 'Enter Transfer Encrypt Token:',
validate: (transferEncryptToken) => (transferEncryptToken.length < 32 ? 'Minimum length is 32' : true),
},
{
type: 'text',
name: 'token',
message: 'Enter Master token :',
validate: (token) => (token.length < 20 ? 'Minimum length for token is 20 characters!' : true),
},
];
const ans = await prompts(questions);
fs.writeFileSync('./.env', envfile.stringify(ans));
console.log('Settings stored in .env');
}
(async function init() {
program.option('-s, --setup', 'Setup/Register this worker');
program.parse(process.argv);
const options = program.opts();
if (options.setup) {
await setup();
return;
}
const worker = new Worker();
worker.requestWork();
})();