mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
* Don't use the names here since they break the all-themes setup in omarchy-nvim * Pin Omarchy npx wrappers to matching node+npx binaries * Fix npx wrappers when mise node is missing * Pin npx wrappers to matching mise node runtime * Isolate npx wrapper runtime from project PATH * Clarify npx wrapper bin resolution --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
52 lines
1.4 KiB
Bash
Executable File
52 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Install an npx wrapper for a given npm package.
|
|
# Usage: omarchy-npx-install <package> [command-name]
|
|
#
|
|
# If command-name is omitted, it defaults to the package name.
|
|
# Example: omarchy-npx-install opencode-ai opencode
|
|
|
|
if [[ -z $1 ]]; then
|
|
echo "Usage: omarchy-npx-install <package> [command-name]"
|
|
exit 1
|
|
fi
|
|
|
|
package=$1
|
|
command=${2:-$1}
|
|
|
|
mkdir -p "$HOME/.local/bin"
|
|
|
|
cat > "$HOME/.local/bin/$command" <<EOF
|
|
#!/bin/bash
|
|
package="$package"
|
|
command="$command"
|
|
|
|
if ! node_root="\$(mise where node@latest 2>/dev/null)"; then
|
|
mise use -g node@latest >/dev/null
|
|
node_root="\$(mise where node@latest)"
|
|
fi
|
|
|
|
node_bin="\$node_root/bin/node"
|
|
npx_bin="\$node_root/bin/npx"
|
|
|
|
# Resolve the package bin inside npx, then run it with node@latest without leaking node@latest into PATH.
|
|
# Some wrappers are aliases, e.g. playwright-cli wraps the playwright bin.
|
|
package_bin_path=\$("\$node_bin" "\$npx_bin" --yes --package "\$package" -- which "\$package" 2>/dev/null)
|
|
|
|
if [[ -n \$package_bin_path ]]; then
|
|
exec "\$node_bin" "\$package_bin_path" "\$@"
|
|
fi
|
|
|
|
# Scoped packages like @openai/codex expose an unscoped bin like codex.
|
|
package_bin_path=\$("\$node_bin" "\$npx_bin" --yes --package "\$package" -- which "\$command" 2>/dev/null)
|
|
|
|
if [[ -n \$package_bin_path ]]; then
|
|
exec "\$node_bin" "\$package_bin_path" "\$@"
|
|
fi
|
|
|
|
echo "Could not resolve npm bin for \$package / \$command" >&2
|
|
exit 127
|
|
EOF
|
|
|
|
chmod +x "$HOME/.local/bin/$command"
|