Permalink
Browse files

Expose environment and arguments to JS

Summary:
Right now from JS there's no way to see the environment variables or arguments that the application was started with.
The main use case for this is to help enable/disable features when being run in a testing environment (as environment variables are the easiest way to communicate).

javache is it okay to reference these constants from JS at startup time? I am planning to disable yellow boxes via an environment variable.

achen1 how easy is it expose these two things for Android as well?

Reviewed By: achen1

Differential Revision: D4395091

fbshipit-source-id: fc318e6a60b8829f7eb4491ea8f3258f68f59c8c
  • Loading branch information...
mmmulani authored and facebook-github-bot committed Jan 13, 2017
1 parent 09072b9 commit 91b7499cf68a349f45e5480f987e4a7d1fdc3aa4
Showing with 41 additions and 0 deletions.
  1. +15 −0 React/Modules/RCTProcessInfo.h
  2. +26 −0 React/Modules/RCTProcessInfo.m
@@ -0,0 +1,15 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <React/RCTBridge.h>
#import <React/RCTBridgeModule.h>
@interface RCTProcessInfo : NSObject <RCTBridgeModule>
@end
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTProcessInfo.h"
@implementation RCTProcessInfo
RCT_EXPORT_MODULE()
- (NSDictionary *)constantsToExport
{
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
return
@{
@"environment": processInfo.environment,
@"arguments": processInfo.arguments,
};
}
@end

0 comments on commit 91b7499

Please sign in to comment.