@e-mc/request 0.11.2 → 0.11.3
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/README.md +4 -4
- package/index.js +21 -17
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.3/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IModule, ModuleConstructor } from "./index";
|
|
@@ -209,9 +209,9 @@ instance.get("http://hostname/path/config.yml", options).then(data => {
|
|
|
209
209
|
|
|
210
210
|
## References
|
|
211
211
|
|
|
212
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
213
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
214
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
212
|
+
- https://www.unpkg.com/@e-mc/types@0.11.3/lib/http.d.ts
|
|
213
|
+
- https://www.unpkg.com/@e-mc/types@0.11.3/lib/request.d.ts
|
|
214
|
+
- https://www.unpkg.com/@e-mc/types@0.11.3/lib/settings.d.ts
|
|
215
215
|
|
|
216
216
|
* https://www.npmjs.com/package/@types/node
|
|
217
217
|
|
package/index.js
CHANGED
|
@@ -345,8 +345,8 @@ function resetAria2() {
|
|
|
345
345
|
ARIA2.PID_TIMER = null;
|
|
346
346
|
}
|
|
347
347
|
function escapeShellQuote(value) {
|
|
348
|
-
value = value.
|
|
349
|
-
return module_1.PLATFORM_WIN32 ? value : value.replace(/
|
|
348
|
+
value = value.replace(/(?<!\\)"/g, '\\"');
|
|
349
|
+
return module_1.PLATFORM_WIN32 ? value : value.replace(/(?<!\\)\$/g, '\\$');
|
|
350
350
|
}
|
|
351
351
|
function failedDns(err, pending) {
|
|
352
352
|
for (const cb of pending) {
|
|
@@ -448,7 +448,7 @@ class Request extends module_1 {
|
|
|
448
448
|
if ((lowest_speed_limit = parseSize(lowest_speed_limit, true)) !== undefined) {
|
|
449
449
|
ARIA2.LOWEST_SPEED_LIMIT = lowest_speed_limit;
|
|
450
450
|
}
|
|
451
|
-
if (always_resume) {
|
|
451
|
+
if (typeof always_resume === 'boolean') {
|
|
452
452
|
ARIA2.ALWAYS_RESUME = always_resume;
|
|
453
453
|
}
|
|
454
454
|
if ((0, types_1.isString)(file_allocation)) {
|
|
@@ -462,7 +462,7 @@ class Request extends module_1 {
|
|
|
462
462
|
break;
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
if (conf_path && this.isPath(conf_path = path.resolve(conf_path))) {
|
|
465
|
+
if (conf_path === '' || (0, types_1.isString)(conf_path) && this.isPath(conf_path = path.resolve(conf_path))) {
|
|
466
466
|
ARIA2.CONF_PATH = conf_path;
|
|
467
467
|
}
|
|
468
468
|
}
|
|
@@ -986,7 +986,7 @@ class Request extends module_1 {
|
|
|
986
986
|
case 'string': {
|
|
987
987
|
const value = opt.trim();
|
|
988
988
|
if (value.startsWith('--')) {
|
|
989
|
-
const match = /^(--[a-z]+[a-z0-9-]*)(=)?\s*(.*)
|
|
989
|
+
const match = /^(--[a-z]+[a-z0-9-]*)(=)?\s*(.*)$/s.exec(value);
|
|
990
990
|
if (match) {
|
|
991
991
|
switch (match[1]) {
|
|
992
992
|
case '--daemon':
|
|
@@ -1188,10 +1188,13 @@ class Request extends module_1 {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
if (binOpts) {
|
|
1190
1190
|
for (const leading of binOpts) {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1191
|
+
if (leading.startsWith('-')) {
|
|
1192
|
+
const pattern = new RegExp(`^${leading}(?:=|$)`);
|
|
1193
|
+
for (let i = 0; i < opts.length; ++i) {
|
|
1194
|
+
if (pattern.test(opts[i])) {
|
|
1195
|
+
opts.splice(i--, i);
|
|
1196
|
+
break;
|
|
1197
|
+
}
|
|
1195
1198
|
}
|
|
1196
1199
|
}
|
|
1197
1200
|
}
|
|
@@ -1208,18 +1211,14 @@ class Request extends module_1 {
|
|
|
1208
1211
|
opts.push(`"${escapeShellQuote(uri)}"`);
|
|
1209
1212
|
args = args.concat(init, opts);
|
|
1210
1213
|
const startTime = Date.now();
|
|
1211
|
-
let out = '', message = ''
|
|
1214
|
+
let out = '', message = '';
|
|
1212
1215
|
const errorResponse = (pid, err) => {
|
|
1213
|
-
aborted = true;
|
|
1214
1216
|
closeTorrent(pid);
|
|
1215
1217
|
reject(err);
|
|
1216
1218
|
};
|
|
1217
1219
|
const { pid, stdout, stderr } = child_process.spawn(module_1.sanitizeCmd(ARIA2.BIN), args, { cwd: pathname, shell: true, signal: this.signal, uid: ARIA2.EXEC_UID, gid: ARIA2.EXEC_GID })
|
|
1218
1220
|
.on('exit', code => {
|
|
1219
1221
|
closeTorrent(pid);
|
|
1220
|
-
if (aborted) {
|
|
1221
|
-
return;
|
|
1222
|
-
}
|
|
1223
1222
|
if (this.aborted) {
|
|
1224
1223
|
errorResponse(pid, (0, types_1.createAbortError)());
|
|
1225
1224
|
return;
|
|
@@ -1255,10 +1254,15 @@ class Request extends module_1 {
|
|
|
1255
1254
|
}
|
|
1256
1255
|
}
|
|
1257
1256
|
}
|
|
1258
|
-
if (result.length > 0
|
|
1259
|
-
|
|
1257
|
+
if (result.length > 0) {
|
|
1258
|
+
if (!silent && LOG_HTTP && LOG_TIMEPROCESS) {
|
|
1259
|
+
this.writeTimeProcess("aria2", uri, startTime, { type: 1024, queue: true, messageUnit, messageUnitMinWidth: 9, bypassLog: true });
|
|
1260
|
+
}
|
|
1261
|
+
this.addLog(types_1.STATUS_TYPE.INFO, out, currentTime, currentTime - startTime, "aria2", uri);
|
|
1262
|
+
}
|
|
1263
|
+
else {
|
|
1264
|
+
this.addLog(types_1.STATUS_TYPE.ERROR, "No files were successfully downloaded", currentTime, currentTime - startTime, "aria2", uri);
|
|
1260
1265
|
}
|
|
1261
|
-
this.addLog(result.length > 0 ? types_1.STATUS_TYPE.INFO : types_1.STATUS_TYPE.ERROR, out, currentTime, currentTime - startTime, "aria2", uri);
|
|
1262
1266
|
resolve(result);
|
|
1263
1267
|
})
|
|
1264
1268
|
.on('error', err => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/request",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "Request constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "BSD-3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/module": "0.11.
|
|
24
|
-
"@e-mc/types": "0.11.
|
|
23
|
+
"@e-mc/module": "0.11.3",
|
|
24
|
+
"@e-mc/types": "0.11.3",
|
|
25
25
|
"combined-stream": "^1.0.8",
|
|
26
26
|
"js-yaml": "^4.1.0",
|
|
27
27
|
"picomatch": "^4.0.2",
|