Permalink
Browse files

repl, feat: add all the builtin modules to the repl global (#377)

  • Loading branch information...
ngot authored and xicilion committed Nov 11, 2017
1 parent c630e3b commit 4f7959a4af574349e22c5010e394b173fa7d9c77
Showing with 13 additions and 0 deletions.
  1. +13 −0 fibjs/src/base/fibjs.cpp
View
@@ -82,6 +82,19 @@ static result_t main_fiber(Isolate* isolate)
s.m_hr = isolate->m_topSandbox->run_main(isolate->m_fname, argv);
} else {
v8::Local<v8::Array> cmds = v8::Array::New(isolate->m_isolate);
RootModule* pModule = RootModule::g_root;
v8::Local<v8::Context> _context = isolate->context();
v8::Local<v8::Object> glob = _context->Global();
while (pModule) {
glob->DefineOwnProperty(_context,
isolate->NewString(pModule->name()),
pModule->getModule(isolate),
(v8::PropertyAttribute)(v8::DontEnum))
.IsJust();
pModule = pModule->m_next;
}
s.m_hr = isolate->m_topSandbox->repl(cmds);
}

0 comments on commit 4f7959a

Please sign in to comment.