feat: mmdc wrapper resolves mermaid-cli from PATH, plus its puppeteer no-sandbox config
This commit is contained in:
1 parent
db2d7aaa42
commit
b4d8701665
2 files changed
+35
No files matched your search
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# mermaid-cli with the puppeteer config that passes --no-sandbox to headless
|
||||||
|
# Chromium. Ubuntu 24.04's AppArmor userns restriction kills Chromium's own
|
||||||
|
# sandbox, so without this nvim's mermaid rendering fails.
|
||||||
|
#
|
||||||
|
# It execs the real mmdc found later on PATH (the npm-global install), skipping
|
||||||
|
# itself. A bare `mmdc` reaches this wrapper only if ~/.local/bin comes before
|
||||||
|
# the npm-global bin on PATH; where it does not, the real mmdc runs without the
|
||||||
|
# sandbox args. (.zshrc currently prepends ~/.npm-global/bin last, so it wins.)
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
self=$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")
|
||||||
|
real=
|
||||||
|
IFS=:
|
||||||
|
for d in $PATH; do
|
||||||
|
[ -n "$d" ] || continue
|
||||||
|
c=$d/mmdc
|
||||||
|
[ -f "$c" ] || continue
|
||||||
|
[ -x "$c" ] || continue
|
||||||
|
[ "$(cd "$d" && pwd -P)/mmdc" = "$self" ] && continue
|
||||||
|
real=$c
|
||||||
|
break
|
||||||
|
done
|
||||||
|
unset IFS
|
||||||
|
|
||||||
|
[ -n "$real" ] || { echo "mmdc: mermaid-cli is not installed (no other mmdc on PATH)" >&2; exit 127; }
|
||||||
|
|
||||||
|
cfg=${XDG_CONFIG_HOME:-$HOME/.config}/mermaid/puppeteer-config.json
|
||||||
|
if [ -r "$cfg" ]; then
|
||||||
|
exec "$real" -p "$cfg" "$@"
|
||||||
|
fi
|
||||||
|
exec "$real" "$@"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["--no-sandbox", "--disable-setuid-sandbox"]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user