Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80713 views
1
var t = require("tap")
2
3
var origCwd = process.cwd()
4
process.chdir(__dirname)
5
6
var glob = require('../')
7
var path = require('path')
8
9
t.test('.', function (t) {
10
glob('/b*/**', { globDebug: true, root: '.' }, function (er, matches) {
11
t.ifError(er)
12
t.like(matches, [])
13
t.end()
14
})
15
})
16
17
18
t.test('a', function (t) {
19
console.error("root=" + path.resolve('a'))
20
glob('/b*/**', { globDebug: true, root: path.resolve('a') }, function (er, matches) {
21
t.ifError(er)
22
var wanted = [
23
'/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f'
24
].map(function (m) {
25
return path.join(path.resolve('a'), m).replace(/\\/g, '/')
26
})
27
28
t.like(matches, wanted)
29
t.end()
30
})
31
})
32
33
t.test('root=a, cwd=a/b', function (t) {
34
glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b') }, function (er, matches) {
35
t.ifError(er)
36
t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
37
return path.join(path.resolve('a'), m).replace(/\\/g, '/')
38
}))
39
t.end()
40
})
41
})
42
43
t.test('cd -', function (t) {
44
process.chdir(origCwd)
45
t.end()
46
})
47
48