|
| 1 | +// An example of a custom setup, useful when testing modules like pacote, |
| 2 | +// which do various things with these git shortcuts. |
| 3 | +const t = require('tap') |
| 4 | +const ghi = require('../git-host-info.js') |
| 5 | +ghi.localhost = { |
| 6 | + protocols: [ 'git' ], |
| 7 | + domain: 'localhost:12345', |
| 8 | + gittemplate: 'git://{domain}/{user}{#committish}', |
| 9 | + treepath: 'not-implemented', |
| 10 | + tarballtemplate: 'http://localhost:18000/repo-HEAD.tgz', |
| 11 | + shortcuttemplate: '{type}:{user}/x{#committish}', |
| 12 | + pathtemplate: '/{user}{#committish}', |
| 13 | + pathmatch: /^\/(repo|submodule-repo)/, |
| 14 | + hashformat: h => h, |
| 15 | + protocols_re: /^(git):$/ |
| 16 | +} |
| 17 | + |
| 18 | +const gh = require('../') |
| 19 | +const f = gh.fromUrl('git://localhost:12345/repo') |
| 20 | + |
| 21 | +t.ok(f, 'got a localhost "hosted" repo') |
| 22 | +t.equal(f.git(), 'git://localhost:12345/repo') |
| 23 | +t.equal(f.tarball(), 'http://localhost:18000/repo-HEAD.tgz') |
| 24 | +t.equal(f.shortcut(), 'localhost:repo/x') |
| 25 | + |
| 26 | +const g = gh.fromUrl('localhost:repo/x') |
| 27 | +t.ok(g, 'got a localhost repo from shortcut') |
| 28 | +t.equal(g.git(), f.git(), 'resolves to the same repo') |
| 29 | +t.equal(g.tarball(), f.tarball(), 'resolves to same tarball') |
0 commit comments