Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80713 views
1
var test = require("tap").test
2
var glob = require('../')
3
process.chdir(__dirname)
4
5
// expose timing issues
6
var lag = 5
7
glob.Glob.prototype._stat = function(o) { return function(f, cb) {
8
var args = arguments
9
setTimeout(function() {
10
o.call(this, f, cb)
11
}.bind(this), lag += 5)
12
}}(glob.Glob.prototype._stat)
13
14
15
test("mark, with **", function (t) {
16
glob("a/*b*/**", {mark: true}, function (er, results) {
17
if (er)
18
throw er
19
var expect =
20
[ 'a/abcdef/',
21
'a/abcdef/g/',
22
'a/abcdef/g/h',
23
'a/abcfed/',
24
'a/abcfed/g/',
25
'a/abcfed/g/h',
26
'a/b/',
27
'a/b/c/',
28
'a/b/c/d',
29
'a/bc/',
30
'a/bc/e/',
31
'a/bc/e/f',
32
'a/cb/',
33
'a/cb/e/',
34
'a/cb/e/f' ]
35
36
t.same(results, expect)
37
t.end()
38
})
39
})
40
41
test("mark, no / on pattern", function (t) {
42
glob("a/*", {mark: true}, function (er, results) {
43
if (er)
44
throw er
45
var expect = [ 'a/abcdef/',
46
'a/abcfed/',
47
'a/b/',
48
'a/bc/',
49
'a/c/',
50
'a/cb/' ]
51
52
if (process.platform !== "win32")
53
expect.push('a/symlink/')
54
55
t.same(results, expect)
56
t.end()
57
}).on('match', function(m) {
58
t.similar(m, /\/$/)
59
})
60
})
61
62
test("mark=false, no / on pattern", function (t) {
63
glob("a/*", function (er, results) {
64
if (er)
65
throw er
66
var expect = [ 'a/abcdef',
67
'a/abcfed',
68
'a/b',
69
'a/bc',
70
'a/c',
71
'a/cb' ]
72
73
if (process.platform !== "win32")
74
expect.push('a/symlink')
75
t.same(results, expect)
76
t.end()
77
}).on('match', function(m) {
78
t.similar(m, /[^\/]$/)
79
})
80
})
81
82
test("mark=true, / on pattern", function (t) {
83
glob("a/*/", {mark: true}, function (er, results) {
84
if (er)
85
throw er
86
var expect = [ 'a/abcdef/',
87
'a/abcfed/',
88
'a/b/',
89
'a/bc/',
90
'a/c/',
91
'a/cb/' ]
92
if (process.platform !== "win32")
93
expect.push('a/symlink/')
94
t.same(results, expect)
95
t.end()
96
}).on('match', function(m) {
97
t.similar(m, /\/$/)
98
})
99
})
100
101
test("mark=false, / on pattern", function (t) {
102
glob("a/*/", function (er, results) {
103
if (er)
104
throw er
105
var expect = [ 'a/abcdef/',
106
'a/abcfed/',
107
'a/b/',
108
'a/bc/',
109
'a/c/',
110
'a/cb/' ]
111
if (process.platform !== "win32")
112
expect.push('a/symlink/')
113
t.same(results, expect)
114
t.end()
115
}).on('match', function(m) {
116
t.similar(m, /\/$/)
117
})
118
})
119
120