@kaynooo/cli-edit 0.11.4 → 0.11.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/cli.js +5 -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 {
|
|
@@ -1584,7 +1584,7 @@ var OPTIONS = {
|
|
|
1584
1584
|
from: { type: "string", short: "f", description: "text to find, taken literally" },
|
|
1585
1585
|
to: { type: "string", short: "t", description: "text to put in its place, empty to delete it" },
|
|
1586
1586
|
count: { type: "string", short: "n", description: "matches expected in each file (default 1)" },
|
|
1587
|
-
all: { type: "boolean", short: "a", description: "replace every match, expecting at least one in each file" },
|
|
1587
|
+
all: { type: "boolean", short: "a", description: "replace every match, expecting at least one in each file, or exactly --count" },
|
|
1588
1588
|
"skip-missing": { type: "boolean", description: "with --all, leave a file where no pair matches alone and list it, instead of failing; the counts still hold for the files that match" },
|
|
1589
1589
|
regex: { type: "boolean", short: "r", description: "--from is a regular expression (^ and $ match each line), --to may use $1, ${1}, $<name> and ${name}, and a \\n or \\t in it is a newline or a tab, \\\\ a backslash" },
|
|
1590
1590
|
"ignore-case": { type: "boolean", short: "i", description: "with --regex, match without regard to case" },
|
|
@@ -1624,7 +1624,7 @@ function pairFrom(item, i, defaults) {
|
|
|
1624
1624
|
fail(`${label}count takes a whole number from 1`);
|
|
1625
1625
|
if (!isFlag(all) || !isFlag(regex) || !isFlag(ignoreCase) || !isFlag(dotAll))
|
|
1626
1626
|
fail(`${label}all, regex, ignoreCase and dotAll take true or false`);
|
|
1627
|
-
const pair = { from, to, count: count ?? defaults.count ?? 1, all: all ?? defaults.all, regex: regex ?? defaults.regex, ignoreCase: ignoreCase ?? defaults.ignoreCase, dotAll: dotAll ?? defaults.dotAll };
|
|
1627
|
+
const pair = { from, to, count: count ?? defaults.count ?? 1, all: count === undefined ? all ?? defaults.all : false, regex: regex ?? defaults.regex, ignoreCase: ignoreCase ?? defaults.ignoreCase, dotAll: dotAll ?? defaults.dotAll };
|
|
1628
1628
|
if ((pair.ignoreCase === true || pair.dotAll === true) && pair.regex !== true)
|
|
1629
1629
|
fail(`${label}ignoreCase and dotAll need regex`);
|
|
1630
1630
|
checkPattern(pair, label);
|
|
@@ -1798,13 +1798,11 @@ async function main(argv) {
|
|
|
1798
1798
|
return inside;
|
|
1799
1799
|
}));
|
|
1800
1800
|
const files = dedupe(given.flat());
|
|
1801
|
-
if (values.count !== undefined && values.all === true)
|
|
1802
|
-
fail("--count and --all exclude each other");
|
|
1803
1801
|
if (values["skip-missing"] === true && values.all !== true)
|
|
1804
1802
|
fail("--skip-missing needs --all");
|
|
1805
1803
|
if ((values["ignore-case"] === true || values.dotall === true) && values.regex !== true)
|
|
1806
1804
|
fail("--ignore-case and --dotall need --regex");
|
|
1807
|
-
const defaults = { count: values.count === undefined ? undefined : wholeNumber(values.count, "count", 1), all: values.all === true, regex: values.regex === true, ignoreCase: values["ignore-case"] === true, dotAll: values.dotall === true };
|
|
1805
|
+
const defaults = { count: values.count === undefined ? undefined : wholeNumber(values.count, "count", 1), all: values.all === true && values.count === undefined, regex: values.regex === true, ignoreCase: values["ignore-case"] === true, dotAll: values.dotall === true };
|
|
1808
1806
|
const edits = await plan(values, files, defaults);
|
|
1809
1807
|
const changes = [];
|
|
1810
1808
|
const problems = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-edit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.6",
|
|
5
5
|
"description": "sub: text replaced in files for Claude Code, written only when every replacement matches as often as expected.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "$npm_execpath build src/cli.ts --target bun --outdir dist",
|
|
35
|
+
"build": "$npm_execpath build src/cli.ts --target bun --outdir dist && $npm_execpath ../../scripts/shell-shebang.ts",
|
|
36
36
|
"sub": "$npm_execpath src/cli.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@kaynooo/utils": "3.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@kaynooo/cli-kit": "0.46.
|
|
42
|
+
"@kaynooo/cli-kit": "0.46.4"
|
|
43
43
|
}
|
|
44
44
|
}
|