dedupe-deps-of-deps.js
1.69 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var sort = require('../');
var test = require('tap').test;
var through = require('through2');
test('dedupe-deps-of-deps', function (t) {
t.plan(1);
var s = sort({ dedupe: true });
var rows = [];
function write (row, enc, next) { rows.push(row); next() }
function end () {
t.deepEqual(rows, [
{
id: '/bar.js',
deps: { baz: '/bar/baz.js' },
source: 'TWO'
},
{
id: '/bar/baz.js',
deps: {},
source: 'THREE'
},
{
id: '/foo.js',
deps: { baz: '/foo/baz.js' },
source: 'TWO',
dedupe: '/bar.js',
sameDeps: true
},
{
id: '/foo/baz.js',
deps: {},
source: 'THREE',
dedupe: '/bar/baz.js',
sameDeps: true
},
{
id: '/main.js',
deps: { './foo': '/foo.js', './bar': '/bar.js' },
source: 'ONE'
}
]);
}
s.pipe(through.obj(write, end));
s.write({
id: '/main.js',
deps: { './foo': '/foo.js', './bar': '/bar.js' },
source: 'ONE'
});
s.write({
id: '/foo.js',
deps: { baz : '/foo/baz.js' },
source: 'TWO'
});
s.write({
id: '/bar.js',
deps: { baz : '/bar/baz.js' },
source: 'TWO'
});
s.write({
id: '/foo/baz.js',
deps: {},
source: 'THREE'
});
s.write({
id: '/bar/baz.js',
deps: {},
source: 'THREE'
});
s.end();
});