Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create example with npx #267

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ const generateWithNormalizedOptions = ({
const commandSync = execa.commandSync;

if (generateExample) {
const reactNativeVersionCommand = 'react-native --version';
const npxVersionCommand = 'npx --version';
const yarnVersionCommand = 'yarn --version';

const checkCliOptions = { stdio: 'inherit' };
const errorRemedyMessage = 'both react-native-cli and yarn CLI tools are needed to generate example project';
const errorRemedyMessage = 'both npx and yarn CLI tools are needed to generate example project';

try {
console.info('CREATE: Check for valid react-native-cli tool version, as needed to generate the example project');
commandSync(reactNativeVersionCommand, checkCliOptions);
console.info(`${reactNativeVersionCommand} ok`);
console.info('CREATE: Check for valid npx version, as needed to generate the example project');
commandSync(npxVersionCommand, checkCliOptions);
console.info(`${npxVersionCommand} ok`);
} catch (e) {
throw new Error(
`${reactNativeVersionCommand} failed; ${errorRemedyMessage}`);
`${npxVersionCommand} failed; ${errorRemedyMessage}`);
}

try {
Expand Down Expand Up @@ -195,7 +195,7 @@ const generateWithNormalizedOptions = ({
const generateExampleApp =
() => {
const exampleReactNativeInitCommand =
`react-native init ${exampleName} --version ${exampleReactNativeVersion}`;
`npx react-native init ${exampleName} --version ${exampleReactNativeVersion}`;

console.info(
`CREATE example app with the following command: ${exampleReactNativeInitCommand}`);
Expand Down