Honor the version of "react" under peerDeps when setting up a new project

Summary:We need this since React 15.0.0 is coming and will break `react-native init`, which currently installs the latest version of React. We'll need some changes to React Native to support 15 that Sebastian is actively working on, but till that lands we want `react-native init` to continue working.
Closes https://github.com/facebook/react-native/pull/6846

Differential Revision: D3148182

Pulled By: sebmarkbage

fb-gh-sync-id: 3df5bc184c0b82d2c9c320c620256c7c8568d90b
fbshipit-source-id: 3df5bc184c0b82d2c9c320c620256c7c8568d90b
This commit is contained in:
James Ide 2016-04-07 00:06:19 -07:00 committed by Facebook Github Bot 9
parent eecdf7d356
commit c30d125050
1 changed files with 12 additions and 1 deletions

View File

@ -96,6 +96,17 @@ module.exports = yeoman.generators.NamedBase.extend({
return;
}
this.npmInstall('react', { '--save': true });
var reactNativePackageJson = require('../../package.json');
var { peerDependencies } = reactNativePackageJson;
if (!peerDependencies) {
return;
}
var reactVersion = peerDependencies.react;
if (!reactVersion) {
return;
}
this.npmInstall(`react@${reactVersion}`, { '--save': true });
}
});