diff --git a/.changeset/crazy-beds-rhyme.md b/.changeset/crazy-beds-rhyme.md new file mode 100644 index 0000000..87b3414 --- /dev/null +++ b/.changeset/crazy-beds-rhyme.md @@ -0,0 +1,5 @@ +--- +'@bomb.sh/tab': patch +--- + +fix: use npx for portable completion scripts instead of absolute paths diff --git a/bin/cli.ts b/bin/cli.ts index 27827a7..8c48fe1 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -71,18 +71,11 @@ async function main() { cli.parse(); } -// function generateCompletionScript(packageManager: string, shell: string) { -// const name = packageManager; -// const executable = process.env.npm_execpath -// ? `${packageManager} exec @bomb.sh/tab ${packageManager}` -// : `node ${process.argv[1]} ${packageManager}`; -// script(shell as any, name, executable); -// } - function generateCompletionScript(packageManager: string, shell: string) { const name = packageManager; - // this always points at the actual file on disk (TESTING) - const executable = `node ${process.argv[1]} ${packageManager}`; + const executable = process.env.npm_config_user_agent + ? `npx --yes @bomb.sh/tab ${packageManager}` + : `node ${process.argv[1]} ${packageManager}`; script(shell as any, name, executable); }