@nklisch/pi-fff-compat 0.1.0 → 0.1.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nklisch/pi-fff-compat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Fast FFF-backed file search through Pi-native find/grep semantics — glob-only file lookup and exact regex/literal grep with no fuzzy fallback.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "nklisch"
|
|
@@ -47,5 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"test": "bun test extensions/*.test.ts"
|
|
50
|
-
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"extensions"
|
|
53
|
+
]
|
|
51
54
|
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import fffCompatSearch from "./fff-compat-search";
|
|
3
|
-
|
|
4
|
-
type ToolDef = { name: string; description?: string };
|
|
5
|
-
type CommandDef = { description?: string };
|
|
6
|
-
|
|
7
|
-
function load() {
|
|
8
|
-
const tools: string[] = [];
|
|
9
|
-
const commands: string[] = [];
|
|
10
|
-
const pi = {
|
|
11
|
-
registerTool: (tool: ToolDef) => {
|
|
12
|
-
tools.push(tool.name);
|
|
13
|
-
},
|
|
14
|
-
registerCommand: (name: string, _options: CommandDef) => {
|
|
15
|
-
commands.push(name);
|
|
16
|
-
},
|
|
17
|
-
on: () => {},
|
|
18
|
-
};
|
|
19
|
-
fffCompatSearch(pi as never);
|
|
20
|
-
return { tools, commands };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const ENV_VARS = ["PI_FFF_COMPAT_OVERRIDE", "PI_FFF_COMPAT_DISABLE"] as const;
|
|
24
|
-
const saved = new Map<string, string | undefined>();
|
|
25
|
-
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
for (const name of ENV_VARS) {
|
|
28
|
-
if (saved.has(name)) {
|
|
29
|
-
const value = saved.get(name);
|
|
30
|
-
if (value === undefined) delete process.env[name];
|
|
31
|
-
else process.env[name] = value;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
saved.clear();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
function setEnv(name: (typeof ENV_VARS)[number], value: string | undefined) {
|
|
38
|
-
if (!saved.has(name)) saved.set(name, process.env[name]);
|
|
39
|
-
if (value === undefined) delete process.env[name];
|
|
40
|
-
else process.env[name] = value;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
describe("pi-fff-compat registration", () => {
|
|
44
|
-
test("default mode registers additive fast_find/fast_grep tools", () => {
|
|
45
|
-
setEnv("PI_FFF_COMPAT_OVERRIDE", undefined);
|
|
46
|
-
setEnv("PI_FFF_COMPAT_DISABLE", undefined);
|
|
47
|
-
const { tools } = load();
|
|
48
|
-
expect(tools).toContain("fast_find");
|
|
49
|
-
expect(tools).toContain("fast_grep");
|
|
50
|
-
expect(tools).not.toContain("find");
|
|
51
|
-
expect(tools).not.toContain("grep");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("override mode registers as find/grep", () => {
|
|
55
|
-
setEnv("PI_FFF_COMPAT_OVERRIDE", "1");
|
|
56
|
-
const { tools } = load();
|
|
57
|
-
expect(tools).toContain("find");
|
|
58
|
-
expect(tools).toContain("grep");
|
|
59
|
-
expect(tools).not.toContain("fast_find");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("disable env registers nothing", () => {
|
|
63
|
-
setEnv("PI_FFF_COMPAT_DISABLE", "1");
|
|
64
|
-
const { tools, commands } = load();
|
|
65
|
-
expect(tools).toHaveLength(0);
|
|
66
|
-
expect(commands).toHaveLength(0);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("status and rescan commands are always registered", () => {
|
|
70
|
-
setEnv("PI_FFF_COMPAT_OVERRIDE", undefined);
|
|
71
|
-
setEnv("PI_FFF_COMPAT_DISABLE", undefined);
|
|
72
|
-
const { commands } = load();
|
|
73
|
-
expect(commands).toContain("fff-compat");
|
|
74
|
-
expect(commands).toContain("fff-compat-rescan");
|
|
75
|
-
});
|
|
76
|
-
});
|