diff --git a/local-cli/server/runServer.js b/local-cli/server/runServer.js index 09501018b65ae6..909b57bcdde7e4 100644 --- a/local-cli/server/runServer.js +++ b/local-cli/server/runServer.js @@ -10,7 +10,6 @@ const InspectorProxy = require('./util/inspectorProxy.js'); const ReactPackager = require('../../packager/react-packager'); -const TerminalReporter = require('../../packager/src/lib/TerminalReporter'); const attachHMRServer = require('./util/attachHMRServer'); const connect = require('connect'); @@ -88,6 +87,21 @@ function getPackagerServer(args, config) { const providesModuleNodeModules = args.providesModuleNodeModules || defaultProvidesModuleNodeModules; + let LogReporter; + if (args.customLogReporterPath) { + try { + // First we let require resolve it, so we can require packages in node_modules + // as expected. eg: require('my-package/reporter'); + LogReporter = require(args.customLogReporterPath); + } catch(e) { + // If that doesn't work, then we next try relative to the cwd, eg: + // require('./reporter'); + LogReporter = require(path.resolve(args.customLogReporterPath)); + } + } else { + LogReporter = require('../../packager/src/lib/TerminalReporter'); + } + return ReactPackager.createServer({ assetExts: defaultAssetExts.concat(args.assetExts), blacklistRE: config.getBlacklistRE(), @@ -98,7 +112,7 @@ function getPackagerServer(args, config) { platforms: defaultPlatforms.concat(args.platforms), projectRoots: args.projectRoots, providesModuleNodeModules: providesModuleNodeModules, - reporter: new TerminalReporter(), + reporter: new LogReporter(), resetCache: args.resetCache, transformModulePath: transformModulePath, verbose: args.verbose, diff --git a/local-cli/server/server.js b/local-cli/server/server.js index 879c5995f407ad..14e8eeeb51de2f 100644 --- a/local-cli/server/server.js +++ b/local-cli/server/server.js @@ -118,6 +118,9 @@ module.exports = { }, { command: '--reset-cache, --resetCache', description: 'Removes cached files', + }, { + command: '--custom-log-reporter-path, --customLogReporterPath [string]', + description: 'Path to a JavaScript file that exports a log reporter as a replacement for TerminalReporter', }, { command: '--verbose', description: 'Enables logging',