Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-07-17 11:09:23 +0300
committerRebecca Turner <me@re-becca.org>2015-07-17 12:49:26 +0300
commitfdb360f0efc540a5f3dc1ab826b7ce68cbcf8d42 (patch)
tree8406073af3fa9b1a49b8c24de59b391834e57ac0 /test
parent5656baaf14dd88624d7608a2b804bd1410890815 (diff)
link: Fix linking of scoped modules
PR-URL: https://github.com/npm/npm/pull/8975 Fixes: https://github.com/npm/npm/issues/8874
Diffstat (limited to 'test')
-rw-r--r--test/tap/link.js48
1 files changed, 47 insertions, 1 deletions
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'),