Export '__in_embed' switch that is defined and set to true, when running napa in embed mode (#64)

This commit is contained in:
Asi Bross 2017-09-25 14:42:05 -07:00 коммит произвёл GitHub
Родитель c18c03cefc
Коммит a2f231f9a6
1 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -211,7 +211,7 @@ namespace {
(void)module->CreateDataProperty(context, v8_helpers::MakeV8String(isolate, "paths"), v8::Array::New(isolate));
(void)module->CreateDataProperty(context, v8_helpers::MakeV8String(isolate, "id"), v8_helpers::MakeV8String(isolate, id));
(void)module->CreateDataProperty(context, v8_helpers::MakeV8String(isolate, "filename"), v8_helpers::MakeV8String(isolate, id));
// Setup 'module.require'.
if (!parentContext.IsEmpty()) {
auto requireKey = v8_helpers::MakeV8String(isolate, "require");
@ -220,10 +220,15 @@ namespace {
(void)exports->CreateDataProperty(context, v8_helpers::MakeV8String(isolate, "module"), module);
(void)exports->CreateDataProperty(context, v8_helpers::MakeV8String(isolate, "exports"),
module->Get(v8_helpers::MakeV8String(isolate, "exports"))->ToObject());
module->Get(v8_helpers::MakeV8String(isolate, "exports"))->ToObject());
// Set '__in_napa' variable in all modules context to distinguish node and napa runtime.
(void)exports->Set(v8_helpers::MakeV8String(isolate, "__in_napa"), v8::Boolean::New(isolate, true));
}
#ifndef USING_V8_SHARED
// Set '__in_embed' variable in all modules context to distinguish between napa running in node and embedded mode.
(void)exports->Set(v8_helpers::MakeV8String(isolate, "__in_embed"), v8::Boolean::New(isolate, true));
#endif
}
} // End of anonymous namespace.