This repository was archived by the owner on Jul 3, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7878 if ( parsed . runtime ) {
7979 if ( typeof parsed . runtime === 'string' ) {
8080 return parsed . runtime ;
81+ } else if ( typeof parsed . runtime === 'object' ) {
82+ if ( typeof parsed . runtime . main === 'string' ) {
83+ return parsed . runtime . main ;
84+ }
85+ } else {
86+ throwError ( new Error ( `package.json '${ packageJsonFile } ' runtime (or runtime.main) field value is invalid` ) ) ;
8187 }
82- throwError ( new Error ( `package.json '${ packageJsonFile } ' runtime field value is invalid` ) ) ;
8388 }
8489
8590 return parsed . main || 'index.js' ;
Original file line number Diff line number Diff line change 2323#include < kernel/system-context.h>
2424#include < kernel/initrd.h>
2525#include < kernel/v8platform.h>
26+ #include < string>
27+ #include < string.h>
28+ #include " ../../deps/json11/json11.hpp" /* <json11.hpp>*/
2629
2730namespace rt {
2831
@@ -69,10 +72,23 @@ class Engines {
6972
7073 v8::V8::SetEntropySource (EntropySource);
7174
72- #if 0
73- const char flags[] = "--expose-wasm";
74- v8::V8::SetFlagsFromString(flags, sizeof(flags));
75- #endif
75+ InitrdFile pkg_json = GLOBAL_initrd ()->Get (" /package.json" );
76+ if (!pkg_json.IsEmpty ()) {
77+ const char * pkg_json_cont = (const char *)pkg_json.Data ();
78+
79+ std::string err;
80+ json11::Json root = json11::Json::parse (pkg_json_cont, err);
81+ if (err.empty ()) {
82+ json11::Json runtime = root[" runtime" ];
83+ if (!runtime.is_null () && runtime.is_object ()) {
84+ json11::Json v8flags = runtime[" v8flags" ];
85+ if (!v8flags.is_null () && v8flags.is_string ()) {
86+ const char * flags_str = v8flags.string_value ().c_str ();
87+ v8::V8::SetFlagsFromString (flags_str, strlen (flags_str));
88+ }
89+ }
90+ }
91+ }
7692
7793 v8::V8::InitializePlatform (v8_platform_);
7894 v8::V8::Initialize ();
You can’t perform that action at this time.
0 commit comments