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
a0717fba
Commit
a0717fba
authored
Nov 20, 2018
by
0mkar
Committed by
yann300
Jan 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix conflicts
parent
be872671
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
39 deletions
+46
-39
compiler.js
remix-tests/src/compiler.js
+46
-39
No files found.
remix-tests/src/compiler.js
View file @
a0717fba
...
...
@@ -37,48 +37,55 @@ function compileFileOrFiles (filename, isDirectory, opts, cb) {
// TODO: for now assumes filepath dir contains all tests, later all this
// should be replaced with remix's & browser solidity compiler code
// This logic is wrong
// We should only look into current file if a full file name with path is given
// We should only walk through directory if a directory name is passed
try
{
// walkSync only if it is a directory
fs
.
walkSync
(
filepath
,
foundpath
=>
{
// only process .sol files
if
(
foundpath
.
split
(
'.'
).
pop
()
===
'sol'
)
{
let
c
=
fs
.
readFileSync
(
foundpath
).
toString
()
const
s
=
/^
(
import
)\s[
'"
](
remix_tests.sol|tests.sol
)[
'"
]
;/gm
if
(
foundpath
.
indexOf
(
'_test.sol'
)
>
0
&&
c
.
regexIndexOf
(
s
)
<
0
)
{
c
=
c
.
replace
(
/
(
pragma solidity
\^?\d
+
\.\d
+
\.\d
+;
)
/
,
'$1
\
nimport
\'
remix_tests.sol
\'
;'
)
}
sources
[
foundpath
]
=
{
content
:
c
}
// https://github.com/mikeal/node-utils/blob/master/file/lib/main.js
fs
.
walkSync
=
function
(
start
,
callback
)
{
fs
.
readdirSync
(
start
).
forEach
(
name
=>
{
if
(
name
===
'node_modules'
)
{
return
;
// hack
}
})
}
catch
(
e
)
{
throw
e
}
finally
{
async
.
waterfall
([
function
loadCompiler
(
next
)
{
compiler
=
new
RemixCompiler
()
compiler
.
onInternalCompilerLoaded
()
// compiler.event.register('compilerLoaded', this, function (version) {
next
()
// });
},
function
doCompilation
(
next
)
{
compiler
.
event
.
register
(
'compilationFinished'
,
this
,
function
(
success
,
data
,
source
)
{
next
(
null
,
data
)
})
compiler
.
compile
(
sources
,
filepath
)
var
abspath
=
path
.
join
(
start
,
name
);
if
(
fs
.
statSync
(
abspath
).
isDirectory
())
{
fs
.
walkSync
(
abspath
,
callback
);
}
else
{
callback
(
abspath
);
}
],
function
(
err
,
result
)
{
let
errors
=
(
result
.
errors
||
[]).
filter
((
e
)
=>
e
.
type
===
'Error'
||
e
.
severity
===
'error'
)
if
(
errors
.
length
>
0
)
{
if
(
!
isBrowser
)
require
(
'signale'
).
fatal
(
errors
)
return
cb
(
new
Error
(
'errors compiling'
))
});
};
fs
.
walkSync
(
filepath
,
foundpath
=>
{
// only process .sol files
if
(
foundpath
.
split
(
'.'
).
pop
()
===
'sol'
)
{
let
c
=
fs
.
readFileSync
(
foundpath
).
toString
()
const
s
=
/^
(
import
)\s[
'"
](
remix_tests.sol|tests.sol
)[
'"
]
;/gm
if
(
foundpath
.
indexOf
(
'_test.sol'
)
>
0
&&
c
.
regexIndexOf
(
s
)
<
0
)
{
c
=
c
.
replace
(
/
(
pragma solidity
\^?\d
+
\.\d
+
\.\d
+;
)
/
,
'$1
\
nimport
\'
remix_tests.sol
\'
;'
)
}
cb
(
err
,
result
.
contracts
)
})
}
sources
[
foundpath
]
=
{
content
:
c
}
}
})
async
.
waterfall
([
function
loadCompiler
(
next
)
{
compiler
=
new
RemixCompiler
()
compiler
.
onInternalCompilerLoaded
()
// compiler.event.register('compilerLoaded', this, function (version) {
next
()
// });
},
function
doCompilation
(
next
)
{
compiler
.
event
.
register
(
'compilationFinished'
,
this
,
function
(
success
,
data
,
source
)
{
next
(
null
,
data
)
})
compiler
.
compile
(
sources
,
false
)
}
],
function
(
err
,
result
)
{
let
errors
=
(
result
.
errors
||
[]).
filter
((
e
)
=>
e
.
type
===
'Error'
||
e
.
severity
===
'error'
)
if
(
errors
.
length
>
0
)
{
if
(
!
isBrowser
)
require
(
'signale'
).
fatal
(
errors
)
return
cb
(
new
Error
(
'errors compiling'
))
}
cb
(
err
,
result
.
contracts
)
})
}
function
compileContractSources
(
sources
,
importFileCb
,
opts
,
cb
)
{
...
...
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