-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·46 lines (35 loc) · 847 Bytes
/
index.js
File metadata and controls
executable file
·46 lines (35 loc) · 847 Bytes
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
#!/usr/bin/env node
const path = require("path");
const homedir = require("os").homedir();
const core = require("./core");
process.title = "alien";
const signals = require("@alien.sh/signals");
signals.Register(core.signals.emit);
const ppid = process.argv[2];
if (!ppid) {
console.log("You should run alien using `alien` executable.");
process.exit(1);
}
const checkRunning = pid => {
try {
return process.kill(pid, 0);
} catch (error) {
return error.code === "EPERM";
}
};
setInterval(() => {
if (!checkRunning(ppid)) {
console.log("Alien shell was terminated.");
console.log("Exiting");
process.exit(0);
}
}, 100);
const getPlugins = () => {
try {
return require(path.resolve(homedir, ".alien/plugins.js"));
} catch (e) {
return [];
}
};
core.plugins = getPlugins();
core.start(core);