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
37b83eaf
Commit
37b83eaf
authored
Mar 15, 2020
by
yann300
Committed by
Aniket
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add type for compilation error
parent
755ee4af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
compiler.ts
remix-tests/src/compiler.ts
+3
-3
types.ts
remix-tests/src/types.ts
+15
-0
No files found.
remix-tests/src/compiler.ts
View file @
37b83eaf
...
@@ -2,7 +2,7 @@ import fs from './fileSystem'
...
@@ -2,7 +2,7 @@ import fs from './fileSystem'
import
async
from
'async'
import
async
from
'async'
import
path
from
'path'
import
path
from
'path'
let
RemixCompiler
=
require
(
'remix-solidity'
).
Compiler
let
RemixCompiler
=
require
(
'remix-solidity'
).
Compiler
import
{
SrcIfc
,
CompilerConfiguration
}
from
'./types'
import
{
SrcIfc
,
CompilerConfiguration
,
CompilationErrors
}
from
'./types'
function
regexIndexOf
(
inputString
:
string
,
regex
:
RegExp
,
startpos
:
number
=
0
)
{
function
regexIndexOf
(
inputString
:
string
,
regex
:
RegExp
,
startpos
:
number
=
0
)
{
const
indexOf
=
inputString
.
substring
(
startpos
).
search
(
regex
)
const
indexOf
=
inputString
.
substring
(
startpos
).
search
(
regex
)
...
@@ -132,7 +132,7 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
...
@@ -132,7 +132,7 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
let
errors
=
(
result
.
errors
||
error
).
filter
((
e
)
=>
e
.
type
===
'Error'
||
e
.
severity
===
'error'
)
let
errors
=
(
result
.
errors
||
error
).
filter
((
e
)
=>
e
.
type
===
'Error'
||
e
.
severity
===
'error'
)
if
(
errors
.
length
>
0
)
{
if
(
errors
.
length
>
0
)
{
if
(
!
isBrowser
)
require
(
'signale'
).
fatal
(
errors
)
if
(
!
isBrowser
)
require
(
'signale'
).
fatal
(
errors
)
return
cb
(
errors
)
return
cb
(
new
CompilationErrors
(
errors
)
)
}
}
cb
(
err
,
result
.
contracts
,
result
.
sources
)
//return callback with contract details & ASTs
cb
(
err
,
result
.
contracts
,
result
.
sources
)
//return callback with contract details & ASTs
})
})
...
@@ -191,7 +191,7 @@ export function compileContractSources(sources: SrcIfc, compilerConfig: Compiler
...
@@ -191,7 +191,7 @@ export function compileContractSources(sources: SrcIfc, compilerConfig: Compiler
let
errors
=
(
result
.
errors
||
error
).
filter
((
e
)
=>
e
.
type
===
'Error'
||
e
.
severity
===
'error'
)
let
errors
=
(
result
.
errors
||
error
).
filter
((
e
)
=>
e
.
type
===
'Error'
||
e
.
severity
===
'error'
)
if
(
errors
.
length
>
0
)
{
if
(
errors
.
length
>
0
)
{
if
(
!
isBrowser
)
require
(
'signale'
).
fatal
(
errors
)
if
(
!
isBrowser
)
require
(
'signale'
).
fatal
(
errors
)
return
cb
(
errors
)
return
cb
(
new
CompilationErrors
(
errors
)
)
}
}
cb
(
err
,
result
.
contracts
,
result
.
sources
)
// return callback with contract details & ASTs
cb
(
err
,
result
.
contracts
,
result
.
sources
)
// return callback with contract details & ASTs
})
})
...
...
remix-tests/src/types.ts
View file @
37b83eaf
...
@@ -51,6 +51,21 @@ export interface CompilerConfiguration {
...
@@ -51,6 +51,21 @@ export interface CompilerConfiguration {
usingWorker
:
boolean
usingWorker
:
boolean
}
}
export
interface
CompilationErrors
{
name
:
string
,
errors
:
Array
<
Error
>
,
message
:
string
}
export
class
CompilationErrors
extends
Error
{
constructor
(
errors
)
{
const
mapError
=
errors
.
map
((
e
)
=>
{
return
e
.
formattedMessage
||
e
.
message
})
super
(
mapError
.
join
(
'
\
n'
))
this
.
errors
=
errors
this
.
name
=
'CompilationErrors'
}
}
/** sources object with name of the file and content **/
/** sources object with name of the file and content **/
////////////
////////////
...
...
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