Changed code to allow registering more than one compiler for same ext.

This commit is contained in:
Richard Ramos 2018-05-30 15:54:37 -04:00 committed by Jonathan Rainville
parent a058fbd349
commit 02de6089ed
1 changed files with 7 additions and 3 deletions

View File

@ -16,15 +16,16 @@ class Compiler {
let pluginCompilers = self.plugins.getPluginsProperty('compilers', 'compilers');
pluginCompilers.forEach(function (compilerObject) {
if(available_compilers[compilerObject.extension] === undefined){
available_compilers[compilerObject.extension] = compilerObject.cb;
if(available_compilers[compilerObject.extension] == undefined){
available_compilers[compilerObject.extension] = [];
}
available_compilers[compilerObject.extension].push(compilerObject.cb);
});
let compiledObject = {};
async.eachObject(available_compilers,
function (extension, compiler, callback) {
function (extension, compilers, callback) {
let matchingFiles = contractFiles.filter(function (file) {
let fileMatch = file.filename.match(/\.[0-9a-z]+$/);
if (fileMatch && (fileMatch[0] === extension)) {
@ -37,6 +38,9 @@ class Compiler {
if (!matchingFiles || !matchingFiles.length) {
return callback();
}
let compiler = compilers[0];
compiler.call(compiler, matchingFiles, function (err, compileResult) {
Object.assign(compiledObject, compileResult);
callback(err, compileResult);