diff --git a/local-cli/core/index.js b/local-cli/core/index.js index 47d099e74..1a9ab03db 100644 --- a/local-cli/core/index.js +++ b/local-cli/core/index.js @@ -106,9 +106,7 @@ const defaultRNConfig = { getDependencyConfig(packageName: string) { const platforms = this.getPlatformConfig(); const folder = path.join(process.cwd(), 'node_modules', packageName); - const rnpm = getRNPMConfig( - path.join(process.cwd(), 'node_modules', packageName), - ); + const rnpm = getRNPMConfig(folder); let config = Object.assign({}, rnpm, { assets: findAssets(folder, rnpm.assets), diff --git a/local-cli/link/__tests__/link.spec.js b/local-cli/link/__tests__/link.spec.js index 9cbe601f2..b44bf22b1 100644 --- a/local-cli/link/__tests__/link.spec.js +++ b/local-cli/link/__tests__/link.spec.js @@ -49,6 +49,20 @@ describe('link', () => { }); }); + it('should accept the name of a dependency with a scope / tag', async () => { + const config = { + getPlatformConfig: () => ({ios: {}, android: {}}), + getProjectConfig: () => ({assets: []}), + getDependencyConfig: sinon.stub().returns({assets: [], commands: {}}), + }; + + const link = require('../link').func; + await link(['@scope/something@latest'], config); + expect( + config.getDependencyConfig.calledWith('@scope/something'), + ).toBeTruthy(); + }); + it('should register native module when android/ios projects are present', done => { const registerNativeModule = sinon.stub(); const dependencyConfig = {android: {}, ios: {}, assets: [], commands: {}}; diff --git a/local-cli/link/link.js b/local-cli/link/link.js index 892e4f710..50d7f16e9 100644 --- a/local-cli/link/link.js +++ b/local-cli/link/link.js @@ -143,9 +143,9 @@ function link(args: Array, config: RNConfig) { } let packageName = args[0]; - // Check if install package by specific version (eg. package@latest) + // Trim the version / tag out of the package name (eg. package@latest) if (packageName !== undefined) { - packageName = packageName.split('@')[0]; + packageName = packageName.replace(/^(.+?)(@.+?)$/gi, '$1'); } const dependencies = getDependencyConfig(