forked from GeneralBots/BotServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.mjs
55 lines (48 loc) · 1.47 KB
/
boot.mjs
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
49
50
51
52
53
54
55
#!/usr/bin/env node
import Fs from 'fs';
import os from 'node:os';
import Path from 'path';
import { exec } from 'child_process';
import pjson from './package.json' assert { type: 'json' };
// Displays version of Node JS being used at runtime and others attributes.
process.stdout.write(`General Bots. BotServer@${pjson.version}, botlib@${pjson.dependencies.botlib}, botbuilder@${pjson.dependencies.botbuilder}, node@${process.version.replace('v', '')}, ${process.platform} ${process.arch} `);
console.log(`\nLoading virtual machine source code files...`);
var __dirname = process.env.PWD || process.cwd();
try {
var run = () => {
import('./dist/src/app.js').then((gb)=> {
gb.GBServer.run()
});
};
var processDist = () => {
if (!Fs.existsSync('dist')) {
console.log(`\n`);
console.log(`Generall Bots: Compiling...`);
exec(Path.join(__dirname, 'node_modules/.bin/tsc'), (err, stdout, stderr) => {
if (err) {
console.error(err);
return;
}
run();
});
} else {
run();
}
};
// Installing modules if it has not been done yet.
if (!Fs.existsSync('node_modules')) {
console.log(`\n`);
console.log(`Generall Bots: Installing modules for the first time, please wait...`);
exec('npm install', (err, stdout, stderr) => {
if (err) {
console.error(err);
return;
}
processDist();
});
} else {
processDist();
}
} catch (e) {
console.log(e);
}