embark-solc/index.js
emizzle d6c2035b54 feat(@embark/embark-solc): Support recursively remapping imports
Changes include:
- Before compilation, for each contract file being compiled, recursively remaps the contract's imports.
- Allowed directories for compilation updated based on the remapped import paths for the contract file.
- Support for code coverage flag.
- Fix for unhandled promise rejection when attempting to use an insufficient version of solc.
2019-02-01 16:07:58 +11:00

34 lines
1.2 KiB
JavaScript

/*global require, module*/
const Compiler = require("./lib/Compiler");
const semver = require('semver');
module.exports = (embark) => {
if (embark.config.embarkConfig.versions.solc) {
const versionPromise = new Promise(function(resolve, reject) {
// Check solc version
});
embark.registerCompiler('.sol', (contractFiles, options, cb) => {
if (!contractFiles || !contractFiles.length) {
return cb();
}
Compiler.getSolcVersion(embark.logger, (err, version) => {
if (err) {
embark.logger.error(err);
embark.logger.error("Error getting solc's version. Will default back to Embark's compiler");
return cb(null, false);
}
if (semver.lt(version, embark.config.embarkConfig.versions.solc)) {
embark.logger.warn(`Current version of solc lower than version in embark.json`);
embark.logger.warn(`Current: ${version} | Wanted: ${embark.config.embarkConfig.versions.solc}`);
embark.logger.warn('Will default back to Embark\'s compiler');
return cb(null, false);
}
Compiler.compileSolc(embark, contractFiles, embark.config.contractDirectories, options, cb);
});
});
}
};