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
3275f1b0
Commit
3275f1b0
authored
Feb 02, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor compiler: rejoin compileFile and compileFiles
parent
84a4d593
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
47 deletions
+19
-47
index.js
index.js
+3
-7
compiler.js
src/compiler.js
+15
-39
testRunner.js
tests/testRunner.js
+1
-1
No files found.
index.js
View file @
3275f1b0
...
@@ -7,14 +7,10 @@ let Compiler = require('./src/compiler.js')
...
@@ -7,14 +7,10 @@ let Compiler = require('./src/compiler.js')
let
Deployer
=
require
(
'./src/deployer.js'
)
let
Deployer
=
require
(
'./src/deployer.js'
)
let
TestRunner
=
require
(
'./src/testRunner.js'
)
let
TestRunner
=
require
(
'./src/testRunner.js'
)
var
runTestFiles
=
function
(
filepath
,
is
_d
irectory
,
web3
)
{
var
runTestFiles
=
function
(
filepath
,
is
D
irectory
,
web3
)
{
async
.
waterfall
([
async
.
waterfall
([
function
compile
(
next
)
{
function
compile
(
next
)
{
if
(
is_directory
)
{
Compiler
.
compileFileOrFiles
(
filepath
,
isDirectory
,
next
)
Compiler
.
compileFiles
(
filepath
,
next
)
}
else
{
Compiler
.
compileFile
(
filepath
,
next
)
}
},
},
function
deployAllContracts
(
compilationResult
,
next
)
{
function
deployAllContracts
(
compilationResult
,
next
)
{
Deployer
.
deployAll
(
compilationResult
,
web3
,
function
(
err
,
contracts
)
{
Deployer
.
deployAll
(
compilationResult
,
web3
,
function
(
err
,
contracts
)
{
...
@@ -23,7 +19,7 @@ var runTestFiles = function(filepath, is_directory, web3) {
...
@@ -23,7 +19,7 @@ var runTestFiles = function(filepath, is_directory, web3) {
}
}
let
contractsToTest
=
[]
let
contractsToTest
=
[]
if
(
is
_d
irectory
)
{
if
(
is
D
irectory
)
{
fs
.
readdirSync
(
filepath
).
forEach
(
filename
=>
{
fs
.
readdirSync
(
filepath
).
forEach
(
filename
=>
{
if
(
filename
.
indexOf
(
'_test.sol'
)
<
0
)
{
if
(
filename
.
indexOf
(
'_test.sol'
)
<
0
)
{
return
return
...
...
src/compiler.js
View file @
3275f1b0
...
@@ -6,49 +6,26 @@ let RemixCompiler = require('remix-solidity').Compiler
...
@@ -6,49 +6,26 @@ let RemixCompiler = require('remix-solidity').Compiler
// TODO: replace this with remix's own compiler code
// TODO: replace this with remix's own compiler code
function
compileFile
(
filename
,
cb
)
{
function
compileFileOrFiles
(
filename
,
isDirectory
,
cb
)
{
let
compiler
let
compiler
,
filepath
const
sources
=
{
'tests.sol'
:
{
content
:
fs
.
readFileSync
(
'sol/tests.sol'
).
toString
()}
}
// TODO: for now assumes filepath dir contains all tests, later all this
// should be replaced with remix's & browser solidity compiler code
let
filepath
=
path
.
dirname
(
filename
)
fs
.
readdirSync
(
filepath
).
forEach
(
file
=>
{
sources
[
file
]
=
{
content
:
fs
.
readFileSync
(
path
.
join
(
filepath
,
file
)).
toString
()}
})
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
)
}
],
function
(
err
,
result
)
{
cb
(
err
,
result
.
contracts
)
})
}
function
compileFiles
(
directory
,
cb
)
{
let
compiler
const
sources
=
{
const
sources
=
{
'tests.sol'
:
{
content
:
fs
.
readFileSync
(
'sol/tests.sol'
).
toString
()}
'tests.sol'
:
{
content
:
fs
.
readFileSync
(
'sol/tests.sol'
).
toString
()}
}
}
// TODO: for now assumes filepath dir contains all tests, later all this
// TODO: for now assumes filepath dir contains all tests, later all this
// should be replaced with remix's & browser solidity compiler code
// should be replaced with remix's & browser solidity compiler code
fs
.
readdirSync
(
directory
).
forEach
(
file
=>
{
if
(
isDirectory
)
{
sources
[
file
]
=
{
content
:
fs
.
readFileSync
(
path
.
join
(
directory
,
file
)).
toString
()}
filepath
=
filename
})
fs
.
readdirSync
(
filename
).
forEach
(
file
=>
{
sources
[
file
]
=
{
content
:
fs
.
readFileSync
(
path
.
join
(
filename
,
file
)).
toString
()}
})
}
else
{
filepath
=
path
.
dirname
(
filename
)
fs
.
readdirSync
(
filepath
).
forEach
(
file
=>
{
sources
[
file
]
=
{
content
:
fs
.
readFileSync
(
path
.
join
(
filepath
,
file
)).
toString
()}
})
}
async
.
waterfall
([
async
.
waterfall
([
function
loadCompiler
(
next
)
{
function
loadCompiler
(
next
)
{
...
@@ -62,7 +39,7 @@ function compileFiles (directory, cb) {
...
@@ -62,7 +39,7 @@ function compileFiles (directory, cb) {
compiler
.
event
.
register
(
'compilationFinished'
,
this
,
function
(
success
,
data
,
source
)
{
compiler
.
event
.
register
(
'compilationFinished'
,
this
,
function
(
success
,
data
,
source
)
{
next
(
null
,
data
)
next
(
null
,
data
)
})
})
compiler
.
compile
(
sources
,
directory
)
compiler
.
compile
(
sources
,
filepath
)
}
}
],
function
(
err
,
result
)
{
],
function
(
err
,
result
)
{
cb
(
err
,
result
.
contracts
)
cb
(
err
,
result
.
contracts
)
...
@@ -70,6 +47,5 @@ function compileFiles (directory, cb) {
...
@@ -70,6 +47,5 @@ function compileFiles (directory, cb) {
}
}
module
.
exports
=
{
module
.
exports
=
{
compileFile
:
compileFile
,
compileFileOrFiles
:
compileFileOrFiles
compileFiles
:
compileFiles
}
}
tests/testRunner.js
View file @
3275f1b0
...
@@ -12,7 +12,7 @@ function compileAndDeploy (filename, callback) {
...
@@ -12,7 +12,7 @@ function compileAndDeploy (filename, callback) {
async
.
waterfall
([
async
.
waterfall
([
function
compile
(
next
)
{
function
compile
(
next
)
{
Compiler
.
compileFile
(
filenam
e
,
next
)
Compiler
.
compileFile
OrFiles
(
filename
,
fals
e
,
next
)
},
},
function
deployAllContracts
(
compilationResult
,
next
)
{
function
deployAllContracts
(
compilationResult
,
next
)
{
Deployer
.
deployAll
(
compilationResult
,
web3
,
next
)
Deployer
.
deployAll
(
compilationResult
,
web3
,
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