From a3893052cd29d6e501deeee8ac0b2d7de42250ba Mon Sep 17 00:00:00 2001 From: 1computer1 Date: Tue, 14 May 2019 20:39:23 -0400 Subject: [PATCH] Add `prepare` option --- config.example.json | 3 ++- src/struct/LanguageHandler.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config.example.json b/config.example.json index d533133..6f66d90 100644 --- a/config.example.json +++ b/config.example.json @@ -11,5 +11,6 @@ ], "memory": "128m", "cpus": "0.5", - "timeout": 10000 + "timeout": 10000, + "prepare": false } diff --git a/src/struct/LanguageHandler.js b/src/struct/LanguageHandler.js index a8a255b..dbfbf0a 100644 --- a/src/struct/LanguageHandler.js +++ b/src/struct/LanguageHandler.js @@ -52,10 +52,13 @@ class LanguageHandler extends AkairoHandler { } buildDocker() { - return Promise.all(this.modules.map(({ loads }) => { - return Promise.all(loads.map(name => { + return Promise.all(this.modules.map(({ id, loads }) => { + return Promise.all(loads.map(async name => { const folder = path.join(__dirname, '../../docker', name); - return util.promisify(childProcess.exec)(`docker build -t "1computer1/comp_iler:${name}" ${folder}`); + await util.promisify(childProcess.exec)(`docker build -t "1computer1/comp_iler:${name}" ${folder}`); + if (this.client.config.prepare) { + await this.setupContainer(id); + } })); })); }