Skip to content
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
7 changes: 6 additions & 1 deletion packages/react-native/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ async function getLatestVersion(registryHost = DEFAULT_REGISTRY_HOST) {
});
}

function parseVersion(version) {
const [major, minor = 0, patch = 0] = version.split('-')[0].split('.');
return major * 1000000 + minor * 1000 + patch;
}

/**
* Warn when users are using `npx react-native init`, to raise awareness of the changes from RFC 0759.
*
Expand Down Expand Up @@ -129,7 +134,7 @@ async function main() {
if (isNpxRuntime && !process.env.SKIP && currentVersion !== HEAD) {
try {
const latest = await getLatestVersion();
if (latest !== currentVersion) {
if (parseVersion(latest) > parseVersion(currentVersion)) {
Comment thread
tido64 marked this conversation as resolved.
const msg = `
${chalk.bold.yellow('WARNING:')} You should run ${chalk.white.bold(
'npx react-native@latest',
Expand Down