Skip to content

Commit e330c3d

Browse files
committed
Fix nwjs#5062: provide process.versions['nw-flavor'] and documentation
1 parent 27089ce commit e330c3d

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

docs/For Users/Advanced/Build Flavors.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
NW.js supports various build flavors for reducing the application size. Currently NW.js supports following build flavors:
77

88
* SDK flavor: has builtin support for DevTools and NaCl plugins. SDK flavor has the same capabilities as the builds before 0.13.0
9-
* NaCL flavor: supports Native Client (NaCl) plugins, but has no builtin DevTools.
109
* Normal flavor: is a minimum build without DevTools and NaCl plugin support.
1110

11+
In your code, you can use `process.versions['nw-flavor']` to see in which flavor your application is running.
12+
1213
See [Build Flavors section in Building NW.js](../../For Developers/Building NW.js.md#build-flavors) for how to build them from source code.

docs/References/Changes to Node.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ A couple of new fields is added to the global `process` object:
1111

1212
* `process.versions['nw']` is set with NW.js's version.
1313
* `process.versions['chromium']` is set with the chromium version which NW.js is based on.
14+
* `process.versions['nw-flavor']` is set to 'sdk' when the binary is SDK build, or 'normal' when the binary is normal build.
1415
* `process.mainModule` is set for the start page (such as `index.html`) as specified in the manifest's [`main`](Manifest Format.md#main) field. However, when the [`node-main`](Manifest Format.md#node-main) field is also specified in the manifest, `process.mainModule` points to the file specified in the `node-main` field.
1516

1617
## require

src/renderer/nw_extensions_renderer_hooks.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,17 @@ void ContextCreationHook(blink::WebLocalFrame* frame, ScriptContext* context) {
241241

242242
g_start_nw_instance_fn(argc, argv, dom_context);
243243
{
244+
#if defined(NWJS_SDK)
245+
std::string flavor = "sdk";
246+
#else
247+
std::string flavor = "normal";
248+
#endif
244249
v8::Local<v8::Script> script =
245250
v8::Script::Compile(v8::String::NewFromUtf8(isolate,
246251
(std::string("process.versions['nw'] = '" NW_VERSION_STRING "';") +
247252
"process.versions['node-webkit'] = '" NW_VERSION_STRING "';"
248253
"process.versions['nw-commit-id'] = '" NW_COMMIT_HASH "';"
254+
"process.versions['nw-flavor'] = '" + flavor + "';"
249255
"process.versions['chromium'] = '" + GetChromiumVersion() + "';").c_str()
250256
));
251257
script->Run();

0 commit comments

Comments
 (0)