forked from raineorshine/solidity-repl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.js
More file actions
executable file
·36 lines (30 loc) · 782 Bytes
/
bin.js
File metadata and controls
executable file
·36 lines (30 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
'use strict'
const Repl = require('./index.js')
const printPrompt = () => process.stdout.write('> ')
console.log('Welcome to the Solidity REPL!')
printPrompt()
let repl = Repl()
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', command => {
if (command === 'quit\n') {
process.exit()
} else if (command === 'clear\n') {
repl = Repl()
printPrompt()
} else {
// evaluate the command
repl(command)
.then(result => {
// if null is returned, it means the last command was not an expression with a return value
if (result !== null) {
console.log(result.toString())
}
})
.catch(err => {
console.log(err)
})
.then(printPrompt)
}
})