mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 14:04:25 -05:00
50d92691c0
Allows to use multiple JSON config files that will be merged into a single configuration
26 lines
732 B
JavaScript
26 lines
732 B
JavaScript
import SquadServerFactory from 'squad-server/factory';
|
|
import printLogo from 'squad-server/logo';
|
|
|
|
async function main() {
|
|
await printLogo();
|
|
|
|
const config = process.env.config;
|
|
const args = process.argv.slice(2);
|
|
const configPaths = args.length ? args : ['./config.json'];
|
|
|
|
if (config && args.length) throw new Error('Cannot accept both a config and config paths.');
|
|
|
|
// create a SquadServer instance
|
|
const server = config
|
|
? await SquadServerFactory.buildFromConfigString(config)
|
|
: await SquadServerFactory.buildFromConfigFiles(configPaths);
|
|
|
|
// watch the server
|
|
await server.watch();
|
|
|
|
// now mount the plugins
|
|
await Promise.all(server.plugins.map(async (plugin) => await plugin.mount()));
|
|
}
|
|
|
|
main();
|