Compile if solidity is fixed version, fixes #1011

pull/5370/head
William Entriken 6 years ago committed by GitHub
parent 230b71420c
commit 1f12ac18d7
  1. 8
      remix-tests/src/compiler.js

@ -26,12 +26,12 @@ function compileFileOrFiles (filename, isDirectory, cb) {
filepath = (isDirectory ? filename : path.dirname(filename))
fs.readdirSync(filepath).forEach(file => {
// only process .sol files
if (file.split('.').pop() === 'sol') {
// only process .sol files named *_test.sol
if (/_test.sol$/.test(file)) {
let c = fs.readFileSync(path.join(filepath, file)).toString()
const s = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm
if (file.indexOf('_test.sol') > 0 && c.regexIndexOf(s) < 0) {
c = c.replace(/(pragma solidity \^\d+\.\d+\.\d+;)/, '$1\nimport \'remix_tests.sol\';')
if (!s.test(c)) {
c = c.replace(/(pragma solidity \^?\d+\.\d+\.\d+;)/, '$1\nimport \'remix_tests.sol\';')
}
sources[file] = { content: c }
}

Loading…
Cancel
Save