Add ability for multiple compilers; add Python2

This commit is contained in:
1computer1 2019-03-13 01:13:49 -04:00
parent 318a485bfb
commit 2dd50d8069
6 changed files with 33 additions and 7 deletions

View file

@ -4,9 +4,21 @@ class Python extends Language {
constructor() {
super('python', {
highlight: 'py',
aliases: ['python', 'py']
aliases: ['python', 'py'],
loads: ['python', 'python2'],
options: {
2: () => ''
}
});
}
runWith(options) {
if (options.has('2')) {
return { id: 'python2', env: {} };
}
return { id: 'python', env: {} };
}
}
module.exports = Python;

View file

@ -5,12 +5,14 @@ class Language extends AkairoModule {
category,
highlight,
aliases,
loads = [id],
options = {}
} = {}) {
super(id, { category });
this.highlight = highlight;
this.aliases = aliases;
this.loads = loads;
this.options = options;
}

View file

@ -51,9 +51,11 @@ class LanguageHandler extends AkairoHandler {
}
buildDocker() {
return Promise.all(this.modules.map(({ id }) => {
const folder = path.join(__dirname, '../../docker', id);
return util.promisify(childProcess.exec)(`docker build -t "1computer1/comp_iler:${id}" ${folder}`);
return Promise.all(this.modules.map(({ loads }) => {
return Promise.all(loads.map(name => {
const folder = path.join(__dirname, '../../docker', name);
return util.promisify(childProcess.exec)(`docker build -t "1computer1/comp_iler:${name}" ${folder}`);
}));
}));
}