@kaynooo/cli-code 0.17.2 → 0.17.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/dist/cli.js +18 -7
- package/package.json +3 -3
package/dist/cli.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 {
|
|
@@ -694,11 +694,20 @@ function wholeNumber(value, name, fallback, min = 1) {
|
|
|
694
694
|
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
|
|
695
695
|
return number;
|
|
696
696
|
}
|
|
697
|
+
function durationMs(text, unit) {
|
|
698
|
+
if (BARE_DURATION.test(text))
|
|
699
|
+
return Number(text) * UNIT_MS[unit];
|
|
700
|
+
if (!DURATION.test(text))
|
|
701
|
+
return 0;
|
|
702
|
+
let ms = 0;
|
|
703
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
704
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
705
|
+
return ms;
|
|
706
|
+
}
|
|
697
707
|
function duration(value, name, fallback, unit = "s") {
|
|
698
708
|
if (value === undefined)
|
|
699
709
|
return fallback;
|
|
700
|
-
const
|
|
701
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
710
|
+
const ms = durationMs(value.trim(), unit);
|
|
702
711
|
if (ms < 1)
|
|
703
712
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
704
713
|
return ms;
|
|
@@ -707,12 +716,14 @@ function isStdinPiped() {
|
|
|
707
716
|
const stat = fstatSync(0);
|
|
708
717
|
return stat.isFIFO() || stat.isFile();
|
|
709
718
|
}
|
|
710
|
-
var WHOLE, DURATION, UNIT_MS;
|
|
719
|
+
var WHOLE, BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
711
720
|
var init_input = __esm(() => {
|
|
712
721
|
init_args();
|
|
713
722
|
WHOLE = /^\d+$/;
|
|
714
|
-
|
|
715
|
-
|
|
723
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
724
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
725
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
726
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
716
727
|
});
|
|
717
728
|
|
|
718
729
|
// ../kit/src/args.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-code",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.3",
|
|
5
5
|
"description": "src: source read by spans, symbols and outlines in one call, the TODO and issue-reference comments of a repository with stale ones flagged, and the files ranked by complexity times git churn.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build": "$npm_execpath build src/cli.ts --target bun --outdir dist",
|
|
36
|
+
"build": "$npm_execpath build src/cli.ts --target bun --outdir dist && $npm_execpath ../../scripts/shell-shebang.ts",
|
|
37
37
|
"src": "$npm_execpath src/cli.ts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@kaynooo/utils": "3.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@kaynooo/cli-kit": "0.46.
|
|
43
|
+
"@kaynooo/cli-kit": "0.46.4"
|
|
44
44
|
}
|
|
45
45
|
}
|