diff --git a/__e2e__/legacyInit.test.js b/__e2e__/legacyInit.test.js index dee3170a7..4e7df6228 100644 --- a/__e2e__/legacyInit.test.js +++ b/__e2e__/legacyInit.test.js @@ -17,6 +17,7 @@ afterEach(() => { test('legacy init through react-native-cli', () => { const templateFiles = [ '.buckconfig', + '.eslintrc.js', '.flowconfig', '.gitattributes', '.gitignore', @@ -64,7 +65,7 @@ test('legacy init through react-native-cli', () => { name: 'TestApp', private: true, scripts: { - start: 'node node_modules/react-native/local-cli/cli.js start', + start: 'react-native start', test: 'jest', }, }); diff --git a/packages/cli/src/cliEntry.js b/packages/cli/src/cliEntry.js index 1798f391e..38ed86516 100644 --- a/packages/cli/src/cliEntry.js +++ b/packages/cli/src/cliEntry.js @@ -169,8 +169,16 @@ async function setupAndRun() { } } + // when we run `config`, we don't want to output anything to the console. We + // expect it to return valid JSON + if (process.argv.includes('config')) { + logger.disable(); + } + const ctx = loadConfig(); + logger.enable(); + setProjectDir(ctx.root); [...commands, ...ctx.commands].forEach(command => addCommand(command, ctx)); diff --git a/packages/platform-android/native_modules.gradle b/packages/platform-android/native_modules.gradle index c70a57b14..4bd826f76 100644 --- a/packages/platform-android/native_modules.gradle +++ b/packages/platform-android/native_modules.gradle @@ -167,7 +167,7 @@ class ReactNativeModules { def cmdProcess def root = getReactNativeProjectRoot() - def command = "node ./node_modules/.bin/react-native config" + def command = "./node_modules/.bin/react-native config" try { cmdProcess = Runtime.getRuntime().exec(command, null, root) diff --git a/packages/platform-ios/native_modules.rb b/packages/platform-ios/native_modules.rb index e2b6965fc..d0c91b60d 100644 --- a/packages/platform-ios/native_modules.rb +++ b/packages/platform-ios/native_modules.rb @@ -5,8 +5,8 @@ # def use_native_modules!(root = "..", packages = nil) if (!packages) - command = "node" - args = ["./node_modules/.bin/react-native", "config"] + command = "./node_modules/.bin/react-native" + args = ["config"] output = "" # Make sure `react-native config` is ran from your project root Dir.chdir(root) do @@ -15,14 +15,7 @@ def use_native_modules!(root = "..", packages = nil) json = [] output.each_line do |line| - case line - when /^warn\s(.+)/ - Pod::UI.warn($1) - when /^(success|info|error|debug)\s(.+)/ - Pod::UI.message($1) - else - json << line - end + json << line end config = JSON.parse(json.join("\n")) packages = config["dependencies"] diff --git a/packages/tools/src/logger.ts b/packages/tools/src/logger.ts index 77cc37138..6ad30997f 100644 --- a/packages/tools/src/logger.ts +++ b/packages/tools/src/logger.ts @@ -3,34 +3,45 @@ import chalk from 'chalk'; const SEPARATOR = ', '; let verbose = false; +let disabled = false; const formatMessages = (messages: Array) => chalk.reset(messages.join(SEPARATOR)); const success = (...messages: Array) => { - console.log(`${chalk.green.bold('success')} ${formatMessages(messages)}`); + if (!disabled) { + console.log(`${chalk.green.bold('success')} ${formatMessages(messages)}`); + } }; const info = (...messages: Array) => { - console.log(`${chalk.cyan.bold('info')} ${formatMessages(messages)}`); + if (!disabled) { + console.log(`${chalk.cyan.bold('info')} ${formatMessages(messages)}`); + } }; const warn = (...messages: Array) => { - console.warn(`${chalk.yellow.bold('warn')} ${formatMessages(messages)}`); + if (!disabled) { + console.warn(`${chalk.yellow.bold('warn')} ${formatMessages(messages)}`); + } }; const error = (...messages: Array) => { - console.error(`${chalk.red.bold('error')} ${formatMessages(messages)}`); + if (!disabled) { + console.error(`${chalk.red.bold('error')} ${formatMessages(messages)}`); + } }; const debug = (...messages: Array) => { - if (verbose) { + if (verbose && !disabled) { console.log(`${chalk.gray.bold('debug')} ${formatMessages(messages)}`); } }; const log = (...messages: Array) => { - console.log(`${formatMessages(messages)}`); + if (!disabled) { + console.log(`${formatMessages(messages)}`); + } }; const setVerbose = (level: boolean) => { @@ -39,6 +50,14 @@ const setVerbose = (level: boolean) => { const isVerbose = () => verbose; +const disable = () => { + disabled = true; +}; + +const enable = () => { + disabled = false; +}; + export default { success, info, @@ -48,4 +67,6 @@ export default { log, setVerbose, isVerbose, + disable, + enable, };