From 52dc70f8feef6486bb956bf71eaae06c7c0b2048 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 --- link/ios/common/isInstalled.js | 4 ++-- link/ios/common/unregisterNativeModule.js | 4 ++-- link/link.js | 2 +- link/unlink.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/link/ios/common/isInstalled.js b/link/ios/common/isInstalled.js index a7a5f2d07..69bcd8bdf 100644 --- a/link/ios/common/isInstalled.js +++ b/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/link/ios/common/unregisterNativeModule.js b/link/ios/common/unregisterNativeModule.js index b42882623..e6d34ada4 100644 --- a/link/ios/common/unregisterNativeModule.js +++ b/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/link/link.js b/link/link.js index 7799b5c17..b77c135f9 100644 --- a/link/link.js +++ b/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/link/unlink.js b/link/unlink.js index 1b504e3ed..91c89ab7e 100644 --- a/link/unlink.js +++ b/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`);