Skip to content

Commit ef1b83f

Browse files
committed
fix: vendor strip-ansi for gateway build
1 parent 7792696 commit ef1b83f

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

flake.nix

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
fi
2828
exec node-gyp "$@"
2929
'';
30+
stripAnsiSrc = ./nix/vendor/strip-ansi;
3031
in {
3132
clawdbot-gateway = prev.clawdbot-gateway.overrideAttrs (old: {
3233
env = (old.env or {}) // {
@@ -70,18 +71,14 @@
7071
${old.installPhase}
7172
pi_dir="$(find "$out/lib/clawdbot/node_modules/.pnpm" -maxdepth 1 -type d -name "@mariozechner+pi-coding-agent@*" | head -n1)"
7273
if [ -z "$pi_dir" ]; then
73-
echo "pi-coding-agent directory not found for strip-ansi link" >&2
74-
exit 1
75-
fi
76-
strip_src="$(find "$out/lib/clawdbot/node_modules/.pnpm" -maxdepth 2 -type d -path "*strip-ansi@*/node_modules/strip-ansi" | head -n1)"
77-
if [ -z "$strip_src" ]; then
78-
echo "strip-ansi not found in pnpm store" >&2
74+
echo "pi-coding-agent directory not found for strip-ansi shim" >&2
7975
exit 1
8076
fi
8177
target="$pi_dir/node_modules/strip-ansi"
8278
rm -rf "$target"
8379
mkdir -p "$(dirname "$target")"
84-
ln -s "$strip_src" "$target"
80+
mkdir -p "$target"
81+
cp -R ${stripAnsiSrc}/* "$target"/
8582
'';
8683
});
8784
};

nix/vendor/strip-ansi/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const ansiRegex = () =>
2+
new RegExp(
3+
'[\\u001B\\u009B][[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nq-uy=><]',
4+
'g'
5+
);
6+
7+
export default function stripAnsi(input) {
8+
if (typeof input !== 'string') {
9+
throw new TypeError('Expected a string');
10+
}
11+
12+
return input.replace(ansiRegex(), '');
13+
}
14+
15+
export { stripAnsi };

nix/vendor/strip-ansi/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "strip-ansi",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"main": "./index.js",
6+
"exports": "./index.js"
7+
}

0 commit comments

Comments
 (0)