From 629a50611620c82b0b342f8e572e3fecf7c54fd3 Mon Sep 17 00:00:00 2001 From: gkodosis Date: Tue, 30 Jun 2020 20:03:34 +0300 Subject: [PATCH] Add nodenv rule --- thefuck/rules/nodenv_no_such_command.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 thefuck/rules/nodenv_no_such_command.py diff --git a/thefuck/rules/nodenv_no_such_command.py b/thefuck/rules/nodenv_no_such_command.py new file mode 100644 index 00000000..27b9f888 --- /dev/null +++ b/thefuck/rules/nodenv_no_such_command.py @@ -0,0 +1,20 @@ +import re +from subprocess import PIPE, Popen +from thefuck.utils import for_app, replace_argument, replace_command +from thefuck.specific.devenv import env_available, COMMON_TYPOS, get_commands + +enabled_by_default = env_available + + +@for_app('nodenv') +def match(command): + return 'nodenv: no such command' in command.output + + +@for_app('nodenv') +def get_new_command(command): + broken = re.findall(r"nodenv: no such command `([^']*)'", command.output)[0] + matched = [replace_argument(command.script, broken, common_typo) + for common_typo in COMMON_TYPOS.get(broken, [])] + matched.extend(replace_command(command, broken, get_commands(command))) + return matched \ No newline at end of file