utilitas 1989.9.34 → 1989.9.38
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/index.mjs +1 -0
- package/lib/storage.mjs +16 -2
- package/lib/tape.mjs +3 -3
- package/package.json +3 -2
package/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// dependencies
|
|
2
2
|
export { default as colors } from 'colors/safe.js';
|
|
3
3
|
export { default as fetch } from 'node-fetch';
|
|
4
|
+
export { Tail as tail } from 'tail';
|
|
4
5
|
export * as base64url from 'base64url';
|
|
5
6
|
export * as fileType from 'file-type';
|
|
6
7
|
export * as geoIp from 'fast-geoip';
|
package/lib/storage.mjs
CHANGED
|
@@ -85,10 +85,10 @@ const assertPath = async (path, type, mode, message, status = 500, options = {})
|
|
|
85
85
|
case '*': case '':
|
|
86
86
|
break;
|
|
87
87
|
case 'R':
|
|
88
|
-
fs.promises.access(path, fs.constants.R_OK);
|
|
88
|
+
await fs.promises.access(path, fs.constants.R_OK);
|
|
89
89
|
break;
|
|
90
90
|
case 'W':
|
|
91
|
-
fs.promises.access(path, fs.constants.R_OK | fs.constants.W_OK);
|
|
91
|
+
await fs.promises.access(path, fs.constants.R_OK | fs.constants.W_OK);
|
|
92
92
|
break;
|
|
93
93
|
default:
|
|
94
94
|
modeErr = message || `Unsupported access mode: '${mode}'.`;
|
|
@@ -98,6 +98,19 @@ const assertPath = async (path, type, mode, message, status = 500, options = {})
|
|
|
98
98
|
return stat;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
+
const isTextFile = async (filename, options) => {
|
|
102
|
+
let [fh, result] = [await fs.promises.open(filename, 'r'), true];
|
|
103
|
+
for (var i = 0; i < ~~options?.length || 1000; i++) {
|
|
104
|
+
const buf = Buffer.alloc(1);
|
|
105
|
+
const bytes = fs.readSync(fh.fd, buf, 0, 1, i);
|
|
106
|
+
if (bytes === 0) { break; } else if (
|
|
107
|
+
bytes === 1 && buf.toString().charCodeAt() === 0
|
|
108
|
+
) { result = false; break; }
|
|
109
|
+
}
|
|
110
|
+
fh.close()
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
|
|
101
114
|
const getConfigFilename = async (options) => {
|
|
102
115
|
options = options || {};
|
|
103
116
|
const file = options.config || path.join(os.homedir(
|
|
@@ -155,6 +168,7 @@ export {
|
|
|
155
168
|
exists,
|
|
156
169
|
getConfig,
|
|
157
170
|
getConfigFilename,
|
|
171
|
+
isTextFile,
|
|
158
172
|
legalFilename,
|
|
159
173
|
readIni,
|
|
160
174
|
readJson,
|
package/lib/tape.mjs
CHANGED
|
@@ -19,9 +19,9 @@ const hookConsole = () => {
|
|
|
19
19
|
console[bakTar] = console[tar];
|
|
20
20
|
console[tar] = function() {
|
|
21
21
|
console[bakTar].apply(console, arguments);
|
|
22
|
-
const str = [...arguments].map(
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const str = [...arguments].map(utilitas.ensureString).join(' ')
|
|
23
|
+
.replace(/\u001b\[\d+m/g, '')
|
|
24
|
+
.split('\n').filter(x => x.length).join('\n').split('');
|
|
25
25
|
while (str.length) {
|
|
26
26
|
const message = str.splice(0, maxLength).join('').trim();
|
|
27
27
|
message.length && log?.(tar, message);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utilitas",
|
|
3
3
|
"description": "Just another common utility for Node.js.",
|
|
4
|
-
"version": "1989.9.
|
|
4
|
+
"version": "1989.9.38",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/Leask/utilitas.git"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@sentry/node": "^6.17.
|
|
28
|
+
"@sentry/node": "^6.17.7",
|
|
29
29
|
"base64url": "^3.0.1",
|
|
30
30
|
"colors": "1.4.0",
|
|
31
31
|
"fast-geoip": "^1.1.58",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"node-mailjet": "^3.3.5",
|
|
41
41
|
"ping": "^0.4.1",
|
|
42
42
|
"qs": "^6.10.3",
|
|
43
|
+
"tail": "^2.2.4",
|
|
43
44
|
"telegraf": "^4.7.0",
|
|
44
45
|
"telesignsdk": "^2.2.1",
|
|
45
46
|
"twilio": "^3.74.0",
|