From fdb360f0efc540a5f3dc1ab826b7ce68cbcf8d42 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 17 Jul 2015 08:09:23 +0000 Subject: link: Fix linking of scoped modules PR-URL: https://github.com/npm/npm/pull/8975 Fixes: https://github.com/npm/npm/issues/8874 --- test/tap/link.js | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/tap/link.js b/test/tap/link.js index 684fcf7e1..869364c29 100644 --- a/test/tap/link.js +++ b/test/tap/link.js @@ -8,6 +8,7 @@ var writeFileSync = require('fs').writeFileSync var common = require('../common-tap.js') var link = path.join(__dirname, 'link') +var linkScoped = path.join(__dirname, 'link-scoped') var linkInstall = path.join(__dirname, 'link-install') var linkRoot = path.join(__dirname, 'link-root') @@ -32,6 +33,18 @@ var readJSON = { license: 'ISC' } +var readScopedJSON = { + name: '@scope/foo', + version: '1.0.0', + description: '', + main: 'index.js', + scripts: { + test: 'echo \"Error: no test specified\" && exit 1' + }, + author: '', + license: 'ISC' +} + var installJSON = { name: 'bar', version: '1.0.0', @@ -54,7 +67,7 @@ test('setup', function (t) { }) }) -test('creates global link', function (t) { +test('create global link', function (t) { process.chdir(link) common.npm(['link'], OPTS, function (err, c, out) { t.ifError(err, 'link has no error') @@ -68,6 +81,20 @@ test('creates global link', function (t) { }) }) +test('create scoped global link', function (t) { + process.chdir(linkScoped) + common.npm(['link'], OPTS, function (err, c, out) { + t.ifError(err, 'link has no error') + common.npm(['ls', '-g'], OPTS, function (err, c, out, stderr) { + t.ifError(err) + t.equal(c, 0) + t.equal(stderr, '', 'got expected stderr') + t.has(out, /@scope[/]foo@1.0.0/, 'creates global link ok') + t.end() + }) + }) +}) + test('link-install the package', function (t) { process.chdir(linkInstall) common.npm(['link', 'foo'], OPTS, function (err) { @@ -81,6 +108,19 @@ test('link-install the package', function (t) { }) }) +test('link-install the scoped package', function (t) { + process.chdir(linkInstall) + common.npm(['link', linkScoped], OPTS, function (err) { + t.ifError(err, 'link-install has no error') + common.npm(['ls'], OPTS, function (err, c, out) { + t.ifError(err) + t.equal(c, 1) + t.has(out, /@scope[/]foo@1.0.0/, 'link-install ok') + t.end() + }) + }) +}) + test('cleanup', function (t) { process.chdir(osenv.tmpdir()) common.npm(['rm', 'foo'], OPTS, function (err, code) { @@ -99,6 +139,7 @@ test('cleanup', function (t) { function cleanup () { rimraf.sync(linkRoot) rimraf.sync(link) + rimraf.sync(linkScoped) rimraf.sync(linkInstall) } @@ -110,6 +151,11 @@ function setup () { path.join(link, 'package.json'), JSON.stringify(readJSON, null, 2) ) + mkdirp.sync(linkScoped) + writeFileSync( + path.join(linkScoped, 'package.json'), + JSON.stringify(readScopedJSON, null, 2) + ) mkdirp.sync(linkInstall) writeFileSync( path.join(linkInstall, 'package.json'), -- cgit v1.2.3