Disable Flow on Packager

Reviewed By: frantic

Differential Revision: D2870105

fb-gh-sync-id: c95db83e40b3558c53614b08240a5361c14e0e6c
This commit is contained in:
Martín Bigio
2016-01-27 15:32:17 -08:00
committed by facebook-github-bot-5
parent f2438b440d
commit c56f280af2
4 changed files with 0 additions and 219 deletions

View File

@@ -96,13 +96,6 @@ function setUpErrorHandler() {
ErrorUtils.setGlobalHandler(handleError);
}
function setUpFlowChecker() {
if (__DEV__) {
var checkFlowAtRuntime = require('checkFlowAtRuntime');
checkFlowAtRuntime();
}
}
/**
* Sets up a set of window environment wrappers that ensure that the
* BatchedBridge is flushed after each tick. In both the case of the
@@ -219,7 +212,6 @@ setUpMapAndSet();
setUpProduct();
setUpWebSockets();
setUpProfile();
setUpFlowChecker();
setUpNumber();
setUpDevTools();

View File

@@ -1,59 +0,0 @@
/**
* Copyright (c) 2015-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.
*
* @providesModule checkFlowAtRuntime
*
*/
'use strict';
function checkFlowAtRuntime() {
var url = getPackagerURL();
if (!url) {
return;
}
fetch(url + 'flow/')
.then(response => response.json())
.then(response => {
if (response.silentError) {
return;
}
throw {
message: response.message,
stack: response.errors.map(err => {
return {
...err,
methodName: err.description,
file: err.filename,
};
}),
};
},
() => {
//if fetch fails, silently give up
})
.done();
}
function getPackagerURL() {
var NativeModules = require('NativeModules');
var scriptURL = (NativeModules
&& NativeModules.SourceCode
&& NativeModules.SourceCode.scriptURL)
|| '';
// extract the url of the packager from the whole scriptURL
// we match until the first / after http(s)://
// i.e. http://www.mypackger.com/debug/my/bundle -> http://www.mypackger.com/
return getFirstOrNull(scriptURL.match(/^https?:\/\/[^/]+\//));
}
function getFirstOrNull(ar) {
return ar ? ar[0] : null;
}
module.exports = checkFlowAtRuntime;