Merge pull request #19 from jhen0409/patch-6

Support new `react-native-macos` package name
This commit is contained in:
Mihail Diordiev 2016-08-10 12:06:42 +03:00 committed by GitHub
commit e6dc434e76
2 changed files with 23 additions and 14 deletions

View File

@ -48,7 +48,7 @@ Change `hostname` and `port` to the values you want.
} }
``` ```
The `injectserver` value can be `reactnative` or `desktop` ([react-native-desktop](https://github.com/ptmt/react-native-desktop)), it used `reactnative` by default. The `injectserver` value can be `reactnative` or `macos` ([react-native-macos](https://github.com/ptmt/react-native-macos)), it used `reactnative` by default.
Then, we can start React Native server and RemoteDev server with one command: Then, we can start React Native server and RemoteDev server with one command:

View File

@ -23,6 +23,9 @@ function log(pass, msg) {
function getModuleName(type) { function getModuleName(type) {
switch (type) { switch (type) {
case 'macos':
return 'react-native-macos';
// react-native-macos is renamed from react-native-desktop
case 'desktop': case 'desktop':
return 'react-native-desktop'; return 'react-native-desktop';
case 'reactnative': case 'reactnative':
@ -35,28 +38,34 @@ function getModulePath(moduleName) {
return path.join(process.cwd(), 'node_modules', moduleName); return path.join(process.cwd(), 'node_modules', moduleName);
} }
function getModule(type) {
var moduleName = getModuleName(type);
var modulePath = getModulePath(moduleName);
if (type === 'desktop' && !fs.existsSync(modulePath)) {
moduleName = getModuleName('macos');
modulePath = getModulePath(moduleName);
}
return {
name: moduleName,
path: modulePath
};
}
if (argv.revert) { if (argv.revert) {
var moduleName = getModuleName(argv.revert); var module = getModule(argv.revert);
var pass = injectServer.revert( var pass = injectServer.revert(module.path, module.name);
getModulePath(moduleName),
moduleName
);
var msg = 'Revert injection of RemoteDev server from React Native local server'; var msg = 'Revert injection of RemoteDev server from React Native local server';
log(pass, msg + (!pass ? ', the file `' + injectServer.fullPath + '` not found.' : '.')); log(pass, msg + (!pass ? ', the file `' + path.join(module.name, injectServer.fullPath) + '` not found.' : '.'));
process.exit(pass ? 0 : 1); process.exit(pass ? 0 : 1);
} }
if (argv.injectserver) { if (argv.injectserver) {
var options = getOptions(argv); var options = getOptions(argv);
var moduleName = getModuleName(argv.injectserver) var module = getModule(argv.injectserver);
var pass = injectServer.inject( var pass = injectServer.inject(module.path, options, module.name);
getModulePath(moduleName),
options,
moduleName
);
var msg = 'Inject RemoteDev server into React Native local server'; var msg = 'Inject RemoteDev server into React Native local server';
log(pass, msg + (pass ? '.' : ', the file `' + injectServer.fullPath + '` not found.')); log(pass, msg + (pass ? '.' : ', the file `' + path.join(module.name, injectServer.fullPath) + '` not found.'));
process.exit(pass ? 0 : 1); process.exit(pass ? 0 : 1);
} }