From ec884890b1f40da42e84202e082b4cef2506bbfc Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Wed, 7 Mar 2018 08:53:55 -0800 Subject: [PATCH] Fixing bugs in link and unlink Summary: Android uses the name of the package, not the config, for the `isInstalled` check. Sending both parameters to `isInstalled` so we have a consistent API. A bug was uncovered in the react-native link command where Android would not unlink because the wrong parameters were being sent to `isInstalled`. Successfully linked and unlinked `react-native-fs` on Windows and Mac. Jest tests pass. [CLI][BUGFIX][local-cli/link/link.js] - Fix issue with `isInstalled` check for Android [CLI][BUGFIX][local-cli/link/unlink.js] - Fix issue with `isInstalled` check for Android [CLI][BUGFIX][local-cli/link/ios/common/unregisterNativeModule.js] - Fix references to unregister implementations. Closes https://github.com/facebook/react-native/pull/18207 Differential Revision: D7180885 Pulled By: hramos fbshipit-source-id: 5f479cd9d7b1ebd8626b461e9dc1f22988e2c61f --- local-cli/link/ios/common/isInstalled.js | 4 ++-- local-cli/link/ios/common/unregisterNativeModule.js | 4 ++-- local-cli/link/link.js | 2 +- local-cli/link/unlink.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/local-cli/link/ios/common/isInstalled.js b/local-cli/link/ios/common/isInstalled.js index a7a5f2d07d192e..69bcd8bdf32d88 100644 --- a/local-cli/link/ios/common/isInstalled.js +++ b/local-cli/link/ios/common/isInstalled.js @@ -1,6 +1,6 @@ const isInstalledIOS = require('../isInstalled'); const isInstalledPods = require('../../pods/isInstalled'); -module.exports = function isInstalled(config, name) { - return isInstalledIOS(config, name) || isInstalledPods(config, name); +module.exports = function isInstalled(projectConfig, name, dependencyConfig) { + return isInstalledIOS(projectConfig, dependencyConfig) || isInstalledPods(projectConfig, dependencyConfig); }; diff --git a/local-cli/link/ios/common/unregisterNativeModule.js b/local-cli/link/ios/common/unregisterNativeModule.js index b42882623fbe34..e6d34ada4cce95 100644 --- a/local-cli/link/ios/common/unregisterNativeModule.js +++ b/local-cli/link/ios/common/unregisterNativeModule.js @@ -1,8 +1,8 @@ const compact = require('lodash').compact; const isInstalledIOS = require('../isInstalled'); const isInstalledPods = require('../../pods/isInstalled'); -const unregisterDependencyIOS = require('../registerNativeModule'); -const unregisterDependencyPods = require('../../pods/registerNativeModule'); +const unregisterDependencyIOS = require('../unregisterNativeModule'); +const unregisterDependencyPods = require('../../pods/unregisterNativeModule'); module.exports = function unregisterNativeModule( name, diff --git a/local-cli/link/link.js b/local-cli/link/link.js index 7799b5c171f6e8..b77c135f9f470f 100644 --- a/local-cli/link/link.js +++ b/local-cli/link/link.js @@ -49,7 +49,7 @@ const linkDependency = (platforms, project, dependency) => { return null; } - const isInstalled = linkConfig.isInstalled(project[platform], dependency.config[platform]); + const isInstalled = linkConfig.isInstalled(project[platform], dependency.name, dependency.config[platform]); if (isInstalled) { log.info(chalk.grey(`Platform '${platform}' module ${dependency.name} is already linked`)); diff --git a/local-cli/link/unlink.js b/local-cli/link/unlink.js index 1b504e3ed4d01a..91c89ab7ec0844 100644 --- a/local-cli/link/unlink.js +++ b/local-cli/link/unlink.js @@ -32,7 +32,7 @@ const unlinkDependency = (platforms, project, dependency, packageName, otherDepe return; } - const isInstalled = linkConfig.isInstalled(project[platform], dependency[platform]); + const isInstalled = linkConfig.isInstalled(project[platform], packageName, dependency[platform]); if (!isInstalled) { log.info(`Platform '${platform}' module ${packageName} is not installed`);