@abtnode/util 1.8.28 → 1.8.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/format-back-slash.js +9 -0
- package/lib/get-folder-size.js +16 -1
- package/lib/log.js +6 -1
- package/package.json +6 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const lodash = require('lodash');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Replace the back slack('\') with forward slash('/')
|
|
5
|
+
* @param {*} str
|
|
6
|
+
* @param {*} flag RegExp flag, default is 'g'
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
module.exports = (str) => lodash.replace(str, new RegExp(lodash.escapeRegExp('\\'), 'g'), '/');
|
package/lib/get-folder-size.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
const getSize = require('get-folder-size');
|
|
1
2
|
const exec = require('child_process').execFile;
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const getOnUnixLike = (dir) => {
|
|
4
5
|
const regex = /^(\d*)/;
|
|
5
6
|
|
|
6
7
|
return new Promise((resolve, reject) => {
|
|
@@ -16,3 +17,17 @@ module.exports = (dir) => {
|
|
|
16
17
|
});
|
|
17
18
|
});
|
|
18
19
|
};
|
|
20
|
+
|
|
21
|
+
const getOnWindows = (dir) => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
getSize(dir, (err, size) => {
|
|
24
|
+
if (err) {
|
|
25
|
+
return reject(err);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return resolve(size);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = process.platform === 'win32' ? getOnWindows : getOnUnixLike;
|
package/lib/log.js
CHANGED
|
@@ -58,7 +58,12 @@ class StreamLog {
|
|
|
58
58
|
if (!file || !fs.existsSync(file)) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
// 测试发现 Windows 下 fs.watch 没有效果,但是 fs.watch 的性能更好,所以只在 windows 下使用 fs.watchFile
|
|
63
|
+
this._tails[level] = new Tail(file, {
|
|
64
|
+
useWatchFile: process.platform === 'win32',
|
|
65
|
+
fsWatchOptions: { interval: 1500 },
|
|
66
|
+
});
|
|
62
67
|
});
|
|
63
68
|
return this._tails;
|
|
64
69
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.30",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/logger": "1.8.
|
|
21
|
+
"@abtnode/constant": "1.8.30",
|
|
22
|
+
"@abtnode/logger": "1.8.30",
|
|
23
23
|
"@arcblock/jwt": "^1.17.23",
|
|
24
|
-
"@blocklet/constant": "1.8.
|
|
24
|
+
"@blocklet/constant": "1.8.30",
|
|
25
25
|
"@ocap/mcrypto": "1.17.23",
|
|
26
26
|
"@ocap/util": "1.17.23",
|
|
27
27
|
"@ocap/wallet": "1.17.23",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"flush-write-stream": "^2.0.0",
|
|
35
35
|
"folder-walker": "^3.2.0",
|
|
36
36
|
"form-data": "^4.0.0",
|
|
37
|
+
"get-folder-size": "^2.0.1",
|
|
37
38
|
"hasha": "^5.2.2",
|
|
38
39
|
"hpagent": "^1.1.0",
|
|
39
40
|
"internal-ip": "^6.2.0",
|
|
@@ -62,5 +63,5 @@
|
|
|
62
63
|
"fs-extra": "^10.1.0",
|
|
63
64
|
"jest": "^27.5.1"
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "cb294f4ee7382c6ef7692b6c2c33ad080fced13e"
|
|
66
67
|
}
|