[ReactNative] Dim packager output

This commit is contained in:
Alex Kotliarskyi 2015-04-17 17:01:18 -07:00
parent ed3aaadc39
commit f7e2e4114b
3 changed files with 23 additions and 17 deletions

View File

@ -10,6 +10,7 @@
var chalk = require('chalk'); var chalk = require('chalk');
var exec = require('child_process').exec; var exec = require('child_process').exec;
var Activity = require('./react-packager/src/Activity');
var hasWarned = {}; var hasWarned = {};
@ -44,20 +45,10 @@ function getFlowTypeCheckMiddleware(options) {
function doFlowTypecheck(res, flowroot, next) { function doFlowTypecheck(res, flowroot, next) {
var flowCmd = 'cd "' + flowroot + '" && flow --json --timeout 20'; var flowCmd = 'cd "' + flowroot + '" && flow --json --timeout 20';
var start = Date.now(); var eventId = Activity.startEvent('flow static typechecks');
// Log start message if flow is slow to let user know something is happening.
var flowSlow = setTimeout(
function() {
console.log(chalk.gray('flow: Running static typechecks.'));
},
500
);
exec(flowCmd, function(flowError, stdout, stderr) { exec(flowCmd, function(flowError, stdout, stderr) {
clearTimeout(flowSlow); Activity.endEvent(eventId);
if (!flowError) { if (!flowError) {
console.log(chalk.gray(
'flow: Typechecks passed (' + (Date.now() - start) + 'ms).')
);
return next(); return next();
} else { } else {
try { try {

View File

@ -0,0 +1,13 @@
/**
* 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.
*/
'use strict';
module.exports = {
dim: function(s) { return s; },
};

View File

@ -8,6 +8,8 @@
*/ */
'use strict'; 'use strict';
var chalk = require('chalk');
var COLLECTION_PERIOD = 1000; var COLLECTION_PERIOD = 1000;
var _endedEvents = Object.create(null); var _endedEvents = Object.create(null);
@ -132,22 +134,22 @@ function _writeAction(action) {
switch (action.action) { switch (action.action) {
case 'startEvent': case 'startEvent':
console.log( console.log(chalk.dim(
'[' + fmtTime + '] ' + '[' + fmtTime + '] ' +
'<START> ' + action.eventName + '<START> ' + action.eventName +
data data
); ));
break; break;
case 'endEvent': case 'endEvent':
var startAction = _eventStarts[action.eventId]; var startAction = _eventStarts[action.eventId];
var startData = startAction.data ? ': ' + JSON.stringify(startAction.data) : ''; var startData = startAction.data ? ': ' + JSON.stringify(startAction.data) : '';
console.log( console.log(chalk.dim(
'[' + fmtTime + '] ' + '[' + fmtTime + '] ' +
'<END> ' + startAction.eventName + '<END> ' + startAction.eventName +
' (' + (action.tstamp - startAction.tstamp) + 'ms)' + ' (' + (action.tstamp - startAction.tstamp) + 'ms)' +
startData startData
); ));
delete _eventStarts[action.eventId]; delete _eventStarts[action.eventId];
break; break;