Skip to content

Commit c0c67ea

Browse files
committed
- bin/console: fix multiline, fix async
Fixes #1
1 parent 25b1755 commit c0c67ea

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/templates/default/bin/console

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const vm = await initVM();
77

88
const isRecoverableError = (error) => {
99
if (error.message.includes('SyntaxError')) {
10-
return /^(unexpected)/i.test(error.message);
10+
return true;
1111
}
1212

1313
return false;
@@ -27,28 +27,19 @@ const rubyEval = async (cmd, context, filename, callback) => {
2727

2828
return callback(null, e.message);
2929
}
30-
callback(null, result);
30+
callback(null, await result.callAsync('inspect'));
3131
}
3232

33-
const rubyWriter = async (output) => {
33+
const rubyWriter = (output) => {
3434
if (!output) return;
3535

3636
if (typeof output === 'string') {
3737
return output;
3838
}
3939

40-
const res = await output.callAsync('inspect');
41-
return res.toString();
40+
return output.toString();
4241
}
4342

44-
vm.eval(`
45-
require_relative "config/environment"
46-
47-
ActiveRecord::Base.logger = Logger.new(STDOUT)
48-
49-
connection = ActiveRecord::Base.connection
50-
`)
51-
5243
const local = repl.start({prompt: '> ', eval: rubyEval, writer: rubyWriter});
5344

5445
local.on('exit', () => {

0 commit comments

Comments
 (0)