Skip to content

Commit b0ac1b7

Browse files
authored
Merge pull request #1973 from ethereum/yann300-patch-38
Fix loading import (remix-tests)
2 parents b453bd2 + 9e684ce commit b0ac1b7

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

libs/remix-tests/src/compiler.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ function isRemixTestFile (path: string) {
4747

4848
function processFile (filePath: string, sources: SrcIfc, isRoot = false) {
4949
const importRegEx = /import ['"](.+?)['"];/g
50-
let group: RegExpExecArray| null = null
5150
const isFileAlreadyInSources: boolean = Object.keys(sources).includes(filePath)
5251

5352
// Return if file is a remix test file or already processed
@@ -62,14 +61,6 @@ function processFile (filePath: string, sources: SrcIfc, isRoot = false) {
6261
content = includeTestLibs.concat(content)
6362
}
6463
sources[filePath] = { content }
65-
importRegEx.exec('') // Resetting state of RegEx
66-
67-
// Process each 'import' in file content
68-
while ((group = importRegEx.exec(content))) {
69-
const importedFile: string = group[1]
70-
const importedFilePath: string = path.join(path.dirname(filePath), importedFile)
71-
processFile(importedFilePath, sources)
72-
}
7364
}
7465

7566
const userAgent = (typeof (navigator) !== 'undefined') && navigator.userAgent ? navigator.userAgent.toLowerCase() : '-'
@@ -123,7 +114,13 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts
123114
} finally {
124115
async.waterfall([
125116
function loadCompiler (next) {
126-
compiler = new RemixCompiler()
117+
compiler = new RemixCompiler((url, cb) => {
118+
try {
119+
cb(null, fs.readFileSync(url, 'utf-8'))
120+
} catch (e) {
121+
cb(e.message)
122+
}
123+
})
127124
if (compilerConfig) {
128125
const { currentCompilerUrl, evmVersion, optimize, runs } = compilerConfig
129126
if (evmVersion) compiler.set('evmVersion', evmVersion)

0 commit comments

Comments
 (0)