From 94a54804287a57832969fe3866126231f32aeca5 Mon Sep 17 00:00:00 2001 From: Chris Brody Date: Wed, 26 Feb 2020 20:09:58 -0500 Subject: [PATCH] prompt for example app name (#8) --- main.js | 13 +++++++++++-- .../__snapshots__/init-with-example.test.js.snap | 13 +++++++++++++ tests/init-with-example/init-with-example.test.js | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 03e668b5..eac34052 100644 --- a/main.js +++ b/main.js @@ -229,6 +229,17 @@ Promise.resolve().then(async () => { initial: true }) + const exampleAppName = generateExampleApp + ? ( + await prompt({ + type: 'text', + name: 'exampleAppName', + message: 'Example app name?', + initial: 'example' + }) + ).exampleAppName + : null + const reactNativeVersion = generateExampleApp ? ( await prompt({ @@ -294,8 +305,6 @@ Promise.resolve().then(async () => { const exampleAppTemplate = exampleTemplates.slice(-1)[0] - const exampleAppName = 'example' - const generateExampleAppOptions = ['--version', reactNativeVersion] await execa( diff --git a/tests/init-with-example/__snapshots__/init-with-example.test.js.snap b/tests/init-with-example/__snapshots__/init-with-example.test.js.snap index e3eb1b60..9e022015 100644 --- a/tests/init-with-example/__snapshots__/init-with-example.test.js.snap +++ b/tests/init-with-example/__snapshots__/init-with-example.test.js.snap @@ -195,6 +195,19 @@ Array [ ], }, }, + Object { + "prompts": Object { + "args": Array [ + Object { + "initial": "example", + "message": "Example app name?", + "name": "exampleAppName", + "onState": [Function], + "type": "text", + }, + ], + }, + }, Object { "prompts": Object { "args": Array [ diff --git a/tests/init-with-example/init-with-example.test.js b/tests/init-with-example/init-with-example.test.js index f2bd8fe6..ac9db132 100644 --- a/tests/init-with-example/init-with-example.test.js +++ b/tests/init-with-example/init-with-example.test.js @@ -15,6 +15,7 @@ mockPromptResponses = { license: { license: 'BSD-4-CLAUSE' }, generateExampleApp: { generateExampleApp: true }, reactNativeVersion: { reactNativeVersion: 'react-native@latest' }, + exampleAppName: { exampleAppName: 'example' }, showReactNativeOutput: { showReactNativeOutput: true } }