@kaynooo/cli-probe 0.4.5 → 0.4.6
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/dist/probe.js +18 -7
- package/package.json +3 -3
package/dist/probe.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#!/
|
|
2
|
-
// @bun
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
// @bun 2>/dev/null; exec bun --no-env-file --config=/dev/null "$0" "$@"
|
|
3
3
|
var __esm = (fn, res, err) => () => {
|
|
4
4
|
if (fn)
|
|
5
5
|
try {
|
|
@@ -575,20 +575,31 @@ function closest(name, names) {
|
|
|
575
575
|
var init_text2 = () => {};
|
|
576
576
|
|
|
577
577
|
// ../kit/src/input.ts
|
|
578
|
+
function durationMs(text, unit) {
|
|
579
|
+
if (BARE_DURATION.test(text))
|
|
580
|
+
return Number(text) * UNIT_MS[unit];
|
|
581
|
+
if (!DURATION.test(text))
|
|
582
|
+
return 0;
|
|
583
|
+
let ms = 0;
|
|
584
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
585
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
586
|
+
return ms;
|
|
587
|
+
}
|
|
578
588
|
function duration(value, name, fallback, unit = "s") {
|
|
579
589
|
if (value === undefined)
|
|
580
590
|
return fallback;
|
|
581
|
-
const
|
|
582
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
591
|
+
const ms = durationMs(value.trim(), unit);
|
|
583
592
|
if (ms < 1)
|
|
584
593
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
585
594
|
return ms;
|
|
586
595
|
}
|
|
587
|
-
var DURATION, UNIT_MS;
|
|
596
|
+
var BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
588
597
|
var init_input = __esm(() => {
|
|
589
598
|
init_args();
|
|
590
|
-
|
|
591
|
-
|
|
599
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
600
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
601
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
602
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
592
603
|
});
|
|
593
604
|
|
|
594
605
|
// ../kit/src/args.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-probe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.6",
|
|
5
5
|
"description": "probe: a site's HTTP version, redirect chain, timings, addresses, TLS certificate and notable headers in one call, with warnings.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "$npm_execpath build src/probe.ts --target bun --outdir dist",
|
|
34
|
+
"build": "$npm_execpath build src/probe.ts --target bun --outdir dist && $npm_execpath ../../scripts/shell-shebang.ts",
|
|
35
35
|
"probe": "$npm_execpath src/probe.ts"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@kaynooo/cli-kit": "0.46.
|
|
38
|
+
"@kaynooo/cli-kit": "0.46.4"
|
|
39
39
|
}
|
|
40
40
|
}
|