-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.js
39 lines (30 loc) · 1.02 KB
/
bootstrap.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
const { execSync, fork } = require('node:child_process'),
path = require('node:path');
/**
* @param {string} command The command to run.
* @param {import("node:child_process").ExecSyncOptions} [options]
* @returns {string | Buffer} The stdout from the command.
*/
const run = (command, options) => execSync(command, { ...(options ?? {}), stdio: 'inherit' });
/**
*
* @param {...string} message
*/
const log = (...message) => void console.log('BOOTSTRAP:', ...message);
const botFolder = path.join(__dirname, 'bot');
log('START!');
// We install packages
log('INSTALLING PACKAGES!');
run('npm install', { cwd: botFolder });
// Then generate prisma files
log('GENERATING PRISMA FILES!');
run('npx prisma generate', { cwd: botFolder });
run('npm remove prisma', { cwd: botFolder });
// Clean up
log('CLEANING UP!');
run('rm -r -f node_modules');
run('rm -r -f .cache');
run('rm -r -f .npm');
log('END!');
// Then run the bot
fork(path.join(botFolder, 'dist', 'index.js'), process.argv, { cwd: botFolder, stdio: 'inherit' });