From 910c1ead320968ff72395d922d35e320d4e2b44c Mon Sep 17 00:00:00 2001 From: Kartik Soneji Date: Mon, 20 Jul 2020 05:44:09 +0600 Subject: [PATCH] Fix double npx prefix. --- thefuck/rules/npx_add_npx_to_command.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/thefuck/rules/npx_add_npx_to_command.py b/thefuck/rules/npx_add_npx_to_command.py index 265204c5..12d374b3 100644 --- a/thefuck/rules/npx_add_npx_to_command.py +++ b/thefuck/rules/npx_add_npx_to_command.py @@ -11,13 +11,17 @@ enabled_by_default = bool(which('npx')) def match(command): return \ 'not found' in command.output.lower() and \ - bool(get_matching_npm_executables_in_cd()) + bool(get_matching_npm_executables_in_cd(command)) def get_new_command(command): + skip = 1 + if command.script_parts[0] == 'npx': + skip += 1 + script_parts = command.script_parts[skip:] return [ - ' '.join(['npx', e, *command.script_parts[1:]]) - for e in get_matching_npm_executables_in_cd() + ' '.join(['npx', e, *script_parts]) + for e in get_matching_npm_executables_in_cd(command) ]