-
-
Notifications
You must be signed in to change notification settings - Fork 252
/
basic.js
106 lines (97 loc) · 2.46 KB
/
basic.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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var rimraf = require('../')
var t = require('tap')
var fs = require('fs')
var fill = require('./fill.js')
t.test('initial clean', function (t) {
rimraf.sync(__dirname + '/target')
t.throws(function () {
fs.statSync(__dirname + '/target')
})
t.end()
})
t.test('sync removal', function (t) {
fill()
t.ok(fs.statSync(__dirname + '/target').isDirectory())
rimraf.sync(__dirname + '/target')
t.throws(function () {
fs.statSync(__dirname + '/target')
})
t.end()
})
t.test('async removal', function (t) {
fill()
t.ok(fs.statSync(__dirname + '/target').isDirectory())
rimraf(__dirname + '/target', function (er) {
if (er)
throw er
t.throws(function () {
fs.statSync(__dirname + '/target')
})
t.end()
})
})
t.test('glob', function (t) {
t.plan(2)
t.test('async', function (t) {
fill()
var glob = require('glob')
var pattern = __dirname + '/target/f-*'
var before = glob.sync(pattern)
t.notEqual(before.length, 0)
rimraf(pattern, function (er) {
if (er)
throw er
var after = glob.sync(pattern)
t.same(after, [])
rimraf.sync(__dirname + '/target')
t.end()
})
})
t.test('sync', function (t) {
fill()
var glob = require('glob')
var pattern = __dirname + '/target/f-*'
var before = glob.sync(pattern)
t.notEqual(before.length, 0)
rimraf.sync(pattern)
var after = glob.sync(pattern)
t.same(after, [])
rimraf.sync(__dirname + '/target')
t.end()
})
})
t.test('no glob', function (t) {
t.plan(2)
t.test('async', function (t) {
fill()
var glob = require('glob')
var pattern = __dirname + '/target/f-*'
var before = glob.sync(pattern)
t.notEqual(before.length, 0)
rimraf(pattern, { disableGlob: true }, function (er) {
if (er)
throw er
var after = glob.sync(pattern)
t.same(after, before)
rimraf.sync(__dirname + '/target')
t.end()
})
})
t.test('sync', function (t) {
fill()
var glob = require('glob')
var pattern = __dirname + '/target/f-*'
var before = glob.sync(pattern)
t.notEqual(before.length, 0)
rimraf.sync(pattern, { disableGlob: true })
var after = glob.sync(pattern)
t.same(after, before)
rimraf.sync(__dirname + '/target')
t.end()
})
})
t.test('verify that cleanup happened', function (t) {
t.throws(fs.statSync.bind(fs, __dirname + '/../target'))
t.throws(fs.statSync.bind(fs, __dirname + '/target'))
t.end()
})