-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
48 lines (46 loc) · 1.2 KB
/
main.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
import './configs/global.js';
import { spawn } from 'child_process';
import cfonts from 'cfonts';
import path from 'path';
import fs from 'fs';
function start(connect) {
console.clear();
cfonts.say('xcoders bot', {
font: 'block',
align: 'center',
gradient: ['#12c2e9', '#c471ed'],
background: 'transparent',
letterSpacing: 1,
transitionGradient: true
});
cfonts.say('Powered By FarhanXCode7', {
font: 'console',
align: 'center',
gradient: ['#DCE35B', '#45B649'],
transitionGradient: true
});
const args = [path.join(connect), ...process.argv.slice(2)];
const pods = spawn(process.argv[0], args, {
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
}).on('message', (data) => {
console.log('[ xcoders ]', data);
switch (data) {
case 'reset':
pods.kill();
start.apply(this, arguments);
break;
}
}).on('error', (error) => {
if (error.code === 'ENOENT') {
const files = global.absoluteUrl(args[0]);
console.error(`File not found: ${files}`);
fs.watchFile(files, () => {
start(files);
fs.unwatchFile(files);
});
} else {
console.error(error);
}
});
}
start('./index.js');