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
This commit is contained in:
Mehdi Mulani 2017-01-13 12:26:23 -08:00 committed by Facebook Github Bot
parent 09072b9d77
commit 91b7499cf6
2 changed files with 41 additions and 0 deletions

View File

@ -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

View File

@ -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