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:
parent
eecdf7d356
commit
c30d125050
|
@ -96,6 +96,17 @@ module.exports = yeoman.generators.NamedBase.extend({
|
||||||
return;
|
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 });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue