• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict'
2var test = require('tap').test
3var common = require('../common-tap.js')
4var path = require('path')
5var rimraf = require('rimraf')
6var mkdirp = require('mkdirp')
7var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
8var fixturepath = path.resolve(basepath, 'npm-test-url-dep')
9var modulepath = path.resolve(basepath, 'node_modules')
10var Tacks = require('tacks')
11var File = Tacks.File
12var Dir = Tacks.Dir
13
14var fixture = new Tacks(
15  Dir({
16    README: File(
17      'just an npm test\n'
18    ),
19    'package.json': File({
20      name: 'npm-test-url-dep',
21      version: '1.2.3',
22      dependencies: {
23        jsonify: 'https://github.com/substack/jsonify/tarball/master',
24        sax: 'isaacs/sax-js',
25        'canonical-host': 'https://github.com/isaacs/canonical-host'
26      }
27    })
28  })
29)
30
31test('setup', function (t) {
32  setup()
33  t.done()
34})
35
36test('url-dep', function (t) {
37  common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
38  function installCheckAndTest (err, code, stdout, stderr) {
39    if (err) throw err
40    t.is(code, 0, 'install went ok')
41    t.done()
42  }
43})
44
45test('cleanup', function (t) {
46  cleanup()
47  t.done()
48})
49
50function setup () {
51  cleanup()
52  fixture.create(fixturepath)
53  mkdirp.sync(modulepath)
54}
55
56function cleanup () {
57  fixture.remove(fixturepath)
58  rimraf.sync(basepath)
59}
60