-
Notifications
You must be signed in to change notification settings - Fork 33
/
realize-package-specifier.js
43 lines (42 loc) · 1.86 KB
/
realize-package-specifier.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict'
var test = require('tap').test
var npa = require('..')
test('realize-package-specifier', function (t) {
t.plan(6)
var result
result = npa('a.tar.gz', '/test/a/b')
t.equal(result.type, 'file', 'local tarball')
result = npa('d', '/test/a/b')
t.equal(result.type, 'range', 'remote package')
result = npa('file:./a.tar.gz', '/test/a/b')
t.equal(result.type, 'file', 'local tarball')
result = npa('file:./b', '/test/a/b')
t.equal(result.type, 'directory', 'local package directory')
result = npa('file:./c', '/test/a/b')
t.equal(result.type, 'directory', 'non-package local directory, specified with a file URL')
result = npa('file:./d', '/test/a/b')
t.equal(result.type, 'directory', 'no local directory, specified with a file URL')
})
test('named realize-package-specifier', function (t) {
t.plan(10)
var result
result = npa('a@a.tar.gz', '/test/a/b')
t.equal(result.type, 'file', 'named local tarball')
result = npa('d@d', '/test/a/b')
t.equal(result.type, 'tag', 'remote package')
result = npa('a@file:./a.tar.gz', '/test/a/b')
t.equal(result.type, 'file', 'local tarball')
result = npa('b@file:./b', '/test/a/b')
t.equal(result.type, 'directory', 'local package directory')
result = npa('c@file:./c', '/test/a/b')
t.equal(result.type, 'directory', 'non-package local directory, specified with a file URL')
result = npa('d@file:./d', '/test/a/b')
t.equal(result.type, 'directory', 'no local directory, specified with a file URL')
result = npa('e@e/2', 'test/a/b')
t.equal(result.type, 'git', 'hosted package dependency is git')
t.equal(result.hosted.type, 'github', 'github package dependency')
result = npa('e@1', '/test/a/b')
t.equal(result.type, 'range', 'range like specifier is never a local file')
result = npa('e@1.0.0', '/test/a/b')
t.equal(result.type, 'version', 'version like specifier is never a local file')
})