• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var fs = require('graceful-fs')
2var path = require('path')
3
4var mkdirp = require('mkdirp')
5var test = require('tap').test
6
7var common = require('../common-tap.js')
8
9var json = {
10  author: 'John Foo',
11  name: 'bad-dep-format',
12  version: '0.0.0',
13  dependencies: {
14    'not-legit': 'bad:not-legit@1.0'
15  }
16}
17
18test('invalid url format returns appropriate error', function (t) {
19  var pkgPath = path.resolve(common.pkg, json.name)
20  mkdirp.sync(pkgPath)
21  fs.writeFileSync(
22    path.join(pkgPath, 'package.json'),
23    JSON.stringify(json, null, 2)
24  )
25  common.npm(['install'], {cwd: pkgPath}, function (err, code, stdout, stderr) {
26    t.ifError(err, 'install ran without error')
27    t.equals(code, 1, 'install exited with code 1')
28    t.match(stderr,
29      /ERR.*Unsupported URL Type/,
30      'Error should report that invalid url-style formats are used')
31    t.end()
32  })
33})
34