diff options
Diffstat (limited to 'deps/npm/test/tap/link.js')
-rw-r--r-- | deps/npm/test/tap/link.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/deps/npm/test/tap/link.js b/deps/npm/test/tap/link.js index 869364c29b5..e2f54552002 100644 --- a/deps/npm/test/tap/link.js +++ b/deps/npm/test/tap/link.js @@ -3,6 +3,7 @@ var osenv = require('osenv') var path = require('path') var rimraf = require('rimraf') var test = require('tap').test +var lstatSync = require('fs').lstatSync var writeFileSync = require('fs').writeFileSync var common = require('../common-tap.js') @@ -10,6 +11,7 @@ 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 linkInside = path.join(linkInstall, 'node_modules', 'inside') var linkRoot = path.join(__dirname, 'link-root') var config = 'prefix = ' + linkRoot @@ -57,6 +59,18 @@ var installJSON = { license: 'ISC' } +var insideInstallJSON = { + name: 'inside', + version: '1.0.0', + description: '', + main: 'index.js', + scripts: { + test: 'echo \"Error: no test specified\" && exit 1' + }, + author: '', + license: 'ISC' +} + test('setup', function (t) { setup() common.npm(['ls', '-g', '--depth=0'], OPTS, function (err, c, out) { @@ -81,6 +95,20 @@ test('create global link', function (t) { }) }) +test('create global inside link', function (t) { + process.chdir(linkInside) + 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, /inside@1.0.0/, 'creates global inside link ok') + t.end() + }) + }) +}) + test('create scoped global link', function (t) { process.chdir(linkScoped) common.npm(['link'], OPTS, function (err, c, out) { @@ -108,6 +136,17 @@ test('link-install the package', function (t) { }) }) +test('link-inside-install fails', function (t) { + process.chdir(linkInstall) + t.notOk(lstatSync(linkInside).isSymbolicLink(), 'directory for linked package is not a symlink to begin with') + common.npm(['link', 'inside'], OPTS, function (err, code) { + t.ifError(err, 'npm removed the linked package without error') + t.notEqual(code, 0, 'link operation failed') + t.notOk(lstatSync(linkInside).isSymbolicLink(), 'directory for linked package has not turned into a symlink') + t.end() + }) +}) + test('link-install the scoped package', function (t) { process.chdir(linkInstall) common.npm(['link', linkScoped], OPTS, function (err) { @@ -141,6 +180,7 @@ function cleanup () { rimraf.sync(link) rimraf.sync(linkScoped) rimraf.sync(linkInstall) + rimraf.sync(linkInside) } function setup () { @@ -161,5 +201,10 @@ function setup () { path.join(linkInstall, 'package.json'), JSON.stringify(installJSON, null, 2) ) + mkdirp.sync(linkInside) + writeFileSync( + path.join(linkInside, 'package.json'), + JSON.stringify(insideInstallJSON, null, 2) + ) writeFileSync(configPath, config) } |