Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
a6b0e140
Commit
a6b0e140
authored
Jan 19, 2021
by
aniket-engg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
semicolons
parent
9c0bb0fb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
compiler.ts
libs/remix-tests/src/compiler.ts
+10
-10
No files found.
libs/remix-tests/src/compiler.ts
View file @
a6b0e140
...
...
@@ -45,15 +45,15 @@ function isRemixTestFile(path: string) {
*/
function
processFile
(
filePath
:
string
,
sources
:
SrcIfc
,
isRoot
=
false
)
{
const
importRegEx
=
/import
[
'"
](
.+
?)[
'"
]
;/g
;
let
group
:
RegExpExecArray
|
null
=
null
;
const
importRegEx
=
/import
[
'"
](
.+
?)[
'"
]
;/g
let
group
:
RegExpExecArray
|
null
=
null
const
isFileAlreadyInSources
:
boolean
=
Object
.
keys
(
sources
).
includes
(
filePath
)
// Return if file is a remix test file or already processed
if
(
isRemixTestFile
(
filePath
)
||
isFileAlreadyInSources
)
return
let
content
:
string
=
fs
.
readFileSync
(
filePath
,
{
encoding
:
'utf-8'
})
;
let
content
:
string
=
fs
.
readFileSync
(
filePath
,
{
encoding
:
'utf-8'
})
const
testFileImportRegEx
=
/^
(
import
)\s[
'"
](
remix_tests.sol|tests.sol
)[
'"
]
;/gm
// import 'remix_tests.sol', if file is a root test contract file and doesn't already have it
...
...
@@ -61,13 +61,13 @@ function processFile(filePath: string, sources: SrcIfc, isRoot = false) {
const
includeTestLibs
=
'
\
nimport
\'
remix_tests.sol
\'
;
\
n'
content
=
includeTestLibs
.
concat
(
content
)
}
sources
[
filePath
]
=
{
content
}
;
importRegEx
.
exec
(
''
)
;
// Resetting state of RegEx
sources
[
filePath
]
=
{
content
}
importRegEx
.
exec
(
''
)
// Resetting state of RegEx
// Process each 'import' in file content
while
((
group
=
importRegEx
.
exec
(
content
)))
{
const
importedFile
:
string
=
group
[
1
]
;
const
importedFilePath
:
string
=
path
.
join
(
path
.
dirname
(
filePath
),
importedFile
)
;
const
importedFile
:
string
=
group
[
1
]
const
importedFilePath
:
string
=
path
.
join
(
path
.
dirname
(
filePath
),
importedFile
)
processFile
(
importedFilePath
,
sources
)
}
}
...
...
@@ -103,11 +103,11 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
}
}
else
{
// walkSync only if it is a directory
let
testFileCount
=
0
;
let
testFileCount
=
0
fs
.
walkSync
(
filepath
,
(
foundpath
:
string
)
=>
{
// only process .sol files
if
(
foundpath
.
split
(
'.'
).
pop
()
===
'sol'
&&
foundpath
.
endsWith
(
'_test.sol'
))
{
testFileCount
++
;
testFileCount
++
processFile
(
foundpath
,
sources
,
true
)
}
})
...
...
@@ -135,7 +135,7 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
compiler
.
loadRemoteVersion
(
currentCompilerUrl
)
compiler
.
event
.
register
(
'compilerLoaded'
,
this
,
function
(
version
)
{
next
()
})
;
})
}
else
{
compiler
.
onInternalCompilerLoaded
()
next
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment