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
497fb0bf
Unverified
Commit
497fb0bf
authored
Jun 22, 2021
by
bunsenstraat
Committed by
GitHub
Jun 22, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1284 from ethereum/remixderror2
parents
82056a5b
51d011f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
remixd.ts
libs/remixd/src/bin/remixd.ts
+20
-3
websocket.ts
libs/remixd/src/websocket.ts
+7
-1
No files found.
libs/remixd/src/bin/remixd.ts
View file @
497fb0bf
...
...
@@ -36,12 +36,21 @@ const ports = {
}
const
killCallBack
:
Array
<
Function
>
=
[]
function
startService
<
S
extends
'git'
|
'hardhat'
|
'folder'
>
(
service
:
S
,
callback
:
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
)
=>
void
)
{
function
startService
<
S
extends
'git'
|
'hardhat'
|
'folder'
>
(
service
:
S
,
callback
:
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
,
error
?:
Error
)
=>
void
)
{
const
socket
=
new
WebSocket
(
ports
[
service
],
{
remixIdeUrl
:
program
.
remixIde
},
()
=>
services
[
service
](
program
.
readOnly
||
false
))
socket
.
start
(
callback
)
killCallBack
.
push
(
socket
.
close
.
bind
(
socket
))
}
function
errorHandler
(
error
:
any
,
service
:
string
)
{
const
port
=
ports
[
service
]
if
(
error
.
code
&&
error
.
code
===
'EADDRINUSE'
)
{
console
.
log
(
'
\
x1b[31m%s
\
x1b[0m'
,
`[ERR] There is already a client running on port
${
port
}
!`
)
}
else
{
console
.
log
(
'
\
x1b[31m%s
\
x1b[0m'
,
'[ERR]'
,
error
)
}
}
(
async
()
=>
{
const
{
version
}
=
require
(
'../package.json'
)
program
.
version
(
version
,
'-v, --version'
)
...
...
@@ -76,7 +85,11 @@ function startService<S extends 'git' | 'hardhat' | 'folder'> (service: S, callb
console
.
log
(
'
\
x1b[33m%s
\
x1b[0m'
,
'[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.'
)
console
.
log
(
'
\
x1b[33m%s
\
x1b[0m'
,
'[WARN] Symbolic links are not forwarded to Remix IDE
\
n'
)
try
{
startService
(
'folder'
,
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
)
=>
{
startService
(
'folder'
,
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
,
error
:
any
)
=>
{
if
(
error
)
{
errorHandler
(
error
,
'hardhat'
)
return
false
}
sharedFolderClient
.
setWebSocket
(
ws
)
sharedFolderClient
.
setupNotifications
(
program
.
sharedFolder
)
sharedFolderClient
.
sharedFolder
(
program
.
sharedFolder
)
...
...
@@ -85,7 +98,11 @@ function startService<S extends 'git' | 'hardhat' | 'folder'> (service: S, callb
const
hardhatConfigFilePath
=
absolutePath
(
'./'
,
program
.
sharedFolder
)
+
'/hardhat.config.js'
const
isHardhatProject
=
fs
.
existsSync
(
hardhatConfigFilePath
)
if
(
isHardhatProject
)
{
startService
(
'hardhat'
,
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
)
=>
{
startService
(
'hardhat'
,
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
,
error
:
Error
)
=>
{
if
(
error
)
{
errorHandler
(
error
,
'hardhat'
)
return
false
}
sharedFolderClient
.
setWebSocket
(
ws
)
sharedFolderClient
.
sharedFolder
(
program
.
sharedFolder
)
})
...
...
libs/remixd/src/websocket.ts
View file @
497fb0bf
...
...
@@ -9,7 +9,7 @@ export default class WebSocket {
constructor
(
public
port
:
number
,
public
opt
:
WebsocketOpt
,
public
getclient
:
()
=>
ServiceClient
)
{}
//eslint-disable-line
start
(
callback
?:
(
ws
:
WS
,
client
:
ServiceClient
)
=>
void
):
void
{
start
(
callback
?:
(
ws
:
WS
,
client
:
ServiceClient
,
error
?:
Error
)
=>
void
):
void
{
this
.
server
=
http
.
createServer
((
request
,
response
)
=>
{
console
.
log
((
new
Date
())
+
' Received request for '
+
request
.
url
)
response
.
writeHead
(
404
)
...
...
@@ -21,9 +21,15 @@ export default class WebSocket {
65521
:
'git'
,
65522
:
'hardhat'
}
this
.
server
.
on
(
'error'
,
(
error
:
Error
)
=>
{
if
(
callback
)
callback
(
null
,
null
,
error
)
})
this
.
server
.
listen
(
this
.
port
,
loopback
,
()
=>
{
console
.
log
(
'
\
x1b[32m%s
\
x1b[0m'
,
`[INFO]
${
new
Date
()}
${
listeners
[
this
.
port
]}
is listening on
${
loopback
}
:
${
this
.
port
}
`
)
})
this
.
wsServer
=
new
WS
.
Server
({
server
:
this
.
server
,
verifyClient
:
(
info
,
done
)
=>
{
...
...
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