-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
32 lines (32 loc) · 849 Bytes
/
test.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
const extractTar = require(".");
const fs = require("fs");
const stream = require("stream");
const logStream = new stream.Writable({
write(chunk, encoding, callback) {
process.stdout.write(`[SYNC] ${chunk}`);
callback();
}
});
const logStreamAsync = new stream.Writable({
write(chunk, encoding, callback) {
process.stdout.write(`[ASYNC] ${chunk}`);
callback();
}
});
try{
fs.rmSync("./test", {recursive: true});
}catch{}
try{
extractTar.extract("./test.tar", logStream);
console.log("[1] Passed\n");
}catch{
console.error("[1] Not passed!");
process.exit(1);
}
extractTar.extract_async("./test.tar", logStreamAsync).then(() => {
console.log("[2] Passed\n");
console.log("All tests done!");
}).catch(() => {
console.error("[2] Not passed!");
process.exit(1);
});