-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (35 loc) · 1.23 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
import "./colors.js";
import {
spawn
} from "child_process"
import fs from "fs";
import * as path from 'path'
import {
fileURLToPath
} from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url))
process.on('uncaughtException', console.error)
function start() {
let args = [path.join(__dirname, '/waspcode.js'), ...process.argv.slice(2)]
let session = spawn(process.argv[0], args, {
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
})
.on('message', async data => {
if (data == 'reset') {
console.log("[WASPCODE]".main, 'Restarting after success requesting code...'.warn, "\n-------------------------------------")
await fs.unlinkSync(path.join(__dirname, "./session/creds.json"));
session.kill(0)
start()
} else if(data == "opened") {
console.log("[WASPCODE]".main, "Restarting waspcode because connection is openned...".warn, "\n-------------------------------------")
await fs.unlinkSync(path.join(__dirname, "./session/creds.json"));
session.kill(0)
start()
}
})
.on('exit', code => {
console.error('Exited with code:'.danger, (code || "NaN").info)
if (code == "." || code == 1 || code == 0) start()
})
}
start()