summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/ci-with-local-dependency.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2019-07-24 23:00:03 -0700
committerMichaƫl Zasso <targos@protonmail.com>2019-08-06 09:05:32 +0200
commitd7d321b071789f08c65dbb11a0e4b3b6a299af44 (patch)
tree1015b8c5da3632fc986b56051a4853ac946c56f4 /deps/npm/test/tap/ci-with-local-dependency.js
parent37d27486fce50bd82b6b5095af880d435ed308f8 (diff)
downloadandroid-node-v8-d7d321b071789f08c65dbb11a0e4b3b6a299af44.tar.gz
android-node-v8-d7d321b071789f08c65dbb11a0e4b3b6a299af44.tar.bz2
android-node-v8-d7d321b071789f08c65dbb11a0e4b3b6a299af44.zip
deps: upgrade npm to 6.10.2
PR-URL: https://github.com/nodejs/node/pull/28853 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'deps/npm/test/tap/ci-with-local-dependency.js')
-rw-r--r--deps/npm/test/tap/ci-with-local-dependency.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/deps/npm/test/tap/ci-with-local-dependency.js b/deps/npm/test/tap/ci-with-local-dependency.js
new file mode 100644
index 0000000000..376dc97818
--- /dev/null
+++ b/deps/npm/test/tap/ci-with-local-dependency.js
@@ -0,0 +1,82 @@
+const fs = require('graceful-fs')
+const path = require('path')
+
+const mkdirp = require('mkdirp')
+const t = require('tap')
+
+const common = require('../common-tap.js')
+
+const pkg = common.pkg + '/package'
+
+const EXEC_OPTS = {
+ cwd: pkg,
+ stdio: [0, 1, 2],
+ env: common.newEnv().extend({
+ npm_config_registry: common.registry
+ })
+}
+
+const localDependencyJson = {
+ name: 'local-dependency',
+ version: '0.0.0',
+ dependencies: {
+ 'test-package': '0.0.0'
+ }
+}
+
+const dependentJson = {
+ name: 'dependent',
+ version: '0.0.0',
+ dependencies: {
+ 'local-dependency': '../local-dependency'
+ }
+}
+
+const target = path.resolve(pkg, '../local-dependency')
+const mr = require('npm-registry-mock')
+let server
+t.teardown(() => {
+ if (server) {
+ server.close()
+ }
+})
+
+t.test('setup', function (t) {
+ mkdirp.sync(target)
+ fs.writeFileSync(
+ path.join(target, 'package.json'),
+ JSON.stringify(localDependencyJson, null, 2)
+ )
+ mkdirp.sync(pkg)
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(dependentJson, null, 2)
+ )
+ mr({ port: common.port }, (er, s) => {
+ if (er) {
+ throw er
+ }
+ server = s
+ t.end()
+ })
+})
+
+t.test('\'npm install\' should install local pkg from sub path', function (t) {
+ common.npm(['install', '--loglevel=silent'], EXEC_OPTS, function (err, code) {
+ if (err) throw err
+ t.equal(code, 0, 'npm install exited with code')
+ t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/package.json')).isFile(), 'local dependency package.json exists')
+ t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/node_modules/test-package')).isDirectory(), 'transitive dependency installed')
+ t.end()
+ })
+})
+
+t.test('\'npm ci\' should work', function (t) {
+ common.npm(['ci', '--loglevel=silent'], EXEC_OPTS, function (err, code) {
+ if (err) throw err
+ t.equal(code, 0, 'npm install exited with code')
+ t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/package.json')).isFile(), 'local dependency package.json exists')
+ t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/node_modules/test-package')).isDirectory(), 'transitive dependency installed')
+ t.end()
+ })
+})