UNPKG

1.72 kBJavaScriptView Raw
1var fsize = require(__dirname + "/index.js");
2var test = function (path, opts) {
3 fsize(path, opts, function (err, size) {
4 if (err) {
5 console.log("\033[7m");
6 console.error(err, size, " bytes");
7 console.log("\033[0m");
8 } else {
9 console.log(path, " ::: ", size, " bytes");
10 }
11 });
12};
13
14var testSync = function (path, opts) {
15 var size;
16 var err;
17 try {
18 size = fsize.sync(path, opts);
19 } catch (err) {
20 console.log("\033[7;35m");
21 console.error(err);
22 console.log("\033[0m");
23 };
24 if (err) {
25 console.log("\033[7;33m");
26 console.error(err, size, " bytes");
27 console.log("\033[0m");
28 } else {
29 console.log("\033[33m",path, " ::: ", size, " bytes\033[0m");
30 }
31};
32
33test(__dirname);
34test(__dirname + "/index.js");
35test(__dirname + "/../../");
36test(__dirname, {
37 logErrors : true,
38 skipErrors : true,
39 countFolders: true,
40 symbolicLinks : true,
41 countSymbolicLinks : true
42});
43test(__dirname + "/index.js", {
44 logErrors : true,
45 skipErrors : true,
46 countFolders: true,
47 symbolicLinks : true,
48 countSymbolicLinks : true
49});
50test(__dirname + "/../../", {
51 logErrors : true,
52 skipErrors : true,
53 countFolders: true,
54 symbolicLinks : true,
55 countSymbolicLinks : true
56});
57
58
59testSync(__dirname);
60testSync(__dirname + "/index.js");
61testSync(__dirname + "/../../");
62testSync(__dirname, {
63 logErrors : true,
64 skipErrors : true,
65 countFolders: true,
66 symbolicLinks : true,
67 countSymbolicLinks : true
68});
69testSync(__dirname + "/index.js", {
70 logErrors : true,
71 skipErrors : true,
72 countFolders: true,
73 symbolicLinks : true,
74 countSymbolicLinks : true
75});
76testSync(__dirname + "/../../", {
77 logErrors : true,
78 skipErrors : true,
79 countFolders: true,
80 symbolicLinks : true,
81 countSymbolicLinks : true
82});
83testSync('/');
84