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:
authorKenan Yildirim <kenan@kenany.me>2015-03-19 19:19:58 +0300
committerForrest L Norvell <forrest@npmjs.com>2015-03-20 10:33:33 +0300
commit3ce3cc242fc345bca6820185a4f5a013c5bc1944 (patch)
treef72483ca1dea709cb9f7c0a1b112264fbb17311f /test
parentbd72c47ce8c58e287d496902c11845c8fea420d6 (diff)
fstream-npm@1.0.2
Error out with a more descriptive message when `bundledDependencies` isn't an array. Includes a test for npm. Also converted to `standard` style.
Diffstat (limited to 'test')
-rw-r--r--test/tap/bundled-dependencies-nonarray.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/test/tap/bundled-dependencies-nonarray.js b/test/tap/bundled-dependencies-nonarray.js
new file mode 100644
index 000000000..938aa629a
--- /dev/null
+++ b/test/tap/bundled-dependencies-nonarray.js
@@ -0,0 +1,77 @@
+var fs = require('graceful-fs')
+var path = require('path')
+
+var osenv = require('osenv')
+var mkdirp = require('mkdirp')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var npm = require('../../lib/npm.js')
+var common = require('../common-tap.js')
+
+var dir = path.resolve(__dirname, 'bundleddependencies')
+var pkg = path.resolve(dir, 'pkg-with-bundled')
+var dep = path.resolve(dir, 'a-bundled-dep')
+
+test('setup', function (t) {
+ bootstrap()
+ t.end()
+})
+
+test('errors on non-array bundleddependencies', function (t) {
+ t.plan(6)
+ process.chdir(pkg)
+ npm.load({},
+ function () {
+ common.npm(['install'], { cwd: pkg }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'npm install ran without issue')
+ t.notOk(code, 'exited with a non-error code')
+ t.notOk(stderr, 'no error output')
+
+ common.npm(['install', './pkg-with-bundled'], { cwd: dir },
+ function (err, code, stdout, stderr) {
+ t.ifError(err, 'npm install ran without issue')
+ t.ok(code, 'exited with a error code')
+ t.ok(stderr.indexOf('be an array') > -1, 'nice error output')
+ }
+ )
+ })
+ }
+ )
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})
+
+var pj = JSON.stringify({
+ name: 'pkg-with-bundled',
+ version: '1.0.0',
+ dependencies: {
+ 'a-bundled-dep': 'file:../a-bundled-dep'
+ },
+ bundledDependencies: {
+ 'a-bundled-dep': 'file:../a-bundled-dep'
+ }
+}, null, 2) + '\n'
+
+var pjDep = JSON.stringify({
+ name: 'a-bundled-dep',
+ version: '2.0.0'
+}, null, 2) + '\n'
+
+function bootstrap () {
+ mkdirp.sync(dir)
+
+ mkdirp.sync(pkg)
+ fs.writeFileSync(path.resolve(pkg, 'package.json'), pj)
+
+ mkdirp.sync(dep)
+ fs.writeFileSync(path.resolve(dep, 'package.json'), pjDep)
+}
+
+function cleanup () {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(dir)
+}