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:
authorJT Turner <jtwebman@gmail.com>2019-02-07 21:42:39 +0300
committerAudrey Eschright <audrey@lifeofaudrey.com>2019-02-14 22:19:49 +0300
commitbbda492d16ccef11ca899e3069d0f82034f076db (patch)
tree38a553661b7f7451ee1bd7fee3f2186ffac83fc1 /test
parent1cc6a0346114875b9e23ff3926c839f37e147d7e (diff)
Fix issue with sub folder local references (#86)
PR-URL: https://github.com/npm/cli/pull/86 Fixes: https://npm.community/t/npm-install-for-package-with-local-dependency-fails/754 Credit: @iarna Credit: @jhecking Reviewed-By: @aeschright
Diffstat (limited to 'test')
-rw-r--r--test/tap/install-at-sub-path-locally.js69
-rw-r--r--test/tap/shrinkwrap-local-dependency.js3
-rw-r--r--test/tap/spec-local-specifiers.js4
3 files changed, 71 insertions, 5 deletions
diff --git a/test/tap/install-at-sub-path-locally.js b/test/tap/install-at-sub-path-locally.js
new file mode 100644
index 000000000..e16b75179
--- /dev/null
+++ b/test/tap/install-at-sub-path-locally.js
@@ -0,0 +1,69 @@
+var fs = require('graceful-fs')
+var path = require('path')
+
+var mkdirp = require('mkdirp')
+var osenv = require('osenv')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var common = require('../common-tap.js')
+
+var pkg = path.join(__dirname, 'install-at-sub-path-locally')
+
+var EXEC_OPTS = { cwd: pkg, stdio: [0, 1, 2] }
+
+var json = {
+ name: 'install-at-sub-path-locally-mock',
+ version: '0.0.0'
+}
+
+var target = '../package@1.2.3'
+
+test('setup', function (t) {
+ cleanup()
+ t.end()
+})
+
+test('\'npm install ../package@1.2.3\' should install local pkg from sub path', function (t) {
+ setup()
+ common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) {
+ if (err) throw err
+ var p = path.resolve(pkg, 'node_modules/install-at-sub-path-locally-mock/package.json')
+ t.equal(code, 0, 'npm install exited with code')
+ t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
+ t.end()
+ })
+})
+
+test('\'running npm install ../package@1.2.3\' should not break on sub path re-install', function (t) {
+ common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) {
+ if (err) throw err
+ var p = path.resolve(pkg, 'node_modules/install-at-sub-path-locally-mock/package.json')
+ t.equal(code, 0, 'npm install exited with code')
+ t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
+ t.end()
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})
+
+function cleanup () {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(pkg)
+ rimraf.sync(path.resolve(pkg, target))
+}
+
+function setup () {
+ cleanup()
+ var root = path.resolve(pkg, target)
+ mkdirp.sync(root)
+ fs.writeFileSync(
+ path.join(root, 'package.json'),
+ JSON.stringify(json, null, 2)
+ )
+ mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ process.chdir(pkg)
+}
diff --git a/test/tap/shrinkwrap-local-dependency.js b/test/tap/shrinkwrap-local-dependency.js
index 58974ad72..d1c33b99a 100644
--- a/test/tap/shrinkwrap-local-dependency.js
+++ b/test/tap/shrinkwrap-local-dependency.js
@@ -20,8 +20,7 @@ var shrinkwrap = {
version: 'file:' + unixFormatPath(path.join('mods', 'mod2')),
dependencies: {
mod1: {
- version: 'file:' + unixFormatPath(path.join('mods', 'mod1')),
- bundled: true
+ version: 'file:' + unixFormatPath(path.join('mods', 'mod1'))
}
}
}
diff --git a/test/tap/spec-local-specifiers.js b/test/tap/spec-local-specifiers.js
index d149b7ea0..3601eee5f 100644
--- a/test/tap/spec-local-specifiers.js
+++ b/test/tap/spec-local-specifiers.js
@@ -585,9 +585,7 @@ test('save behavior', function (t) {
var deps = pjson.dependencies || {}
t.is(deps['sb-transitive'], 'file:../sb-transitive', 'package.json')
var sdep = shrinkwrap.dependencies['sb-transitive'] || {}
- var tdep = sdep.dependencies.sbta
- t.like(tdep, {bundled: true, version: 'file:../sb-transitive/sbta'}, 'npm-shrinkwrap.json transitive dep')
- t.like(sdep, {bundled: null, version: 'file:../sb-transitive'}, 'npm-shrinkwrap.json direct dep')
+ t.like(sdep, {bundled: null, dependencies: null, version: 'file:../sb-transitive'}, 'npm-shrinkwrap.json direct dep')
t.done()
})
})