1/** 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 * 7 * @format 8 */ 9 10'use strict'; 11 12const logPath = process.env.RCT_PACKAGER_LOG_PATH; 13if (logPath != null && logPath !== '') { 14 const JsonReporter = require('metro/src/lib/JsonReporter'); 15 const fs = require('fs'); 16 const path = require('path'); 17 module.exports = class extends JsonReporter { 18 constructor() { 19 fs.mkdirSync(path.dirname(logPath), { 20 recursive: true, 21 }); 22 super(fs.createWriteStream(logPath)); 23 } 24 }; 25} else { 26 module.exports = require('metro/src/lib/TerminalReporter'); 27} 28