mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	#N/A: Cache docker, gem, grunt and yarn output in rules
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| from itertools import dropwhile, takewhile, islice | from itertools import dropwhile, takewhile, islice | ||||||
| import re | import re | ||||||
| import subprocess | import subprocess | ||||||
| from thefuck.utils import replace_command, for_app | from thefuck.utils import replace_command, for_app, which, cache | ||||||
| from thefuck.specific.sudo import sudo_support | from thefuck.specific.sudo import sudo_support | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -20,6 +20,10 @@ def get_docker_commands(): | |||||||
|     return [line.strip().split(' ')[0] for line in lines] |     return [line.strip().split(' ')[0] for line in lines] | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if which('docker'): | ||||||
|  |     get_docker_commands = cache(which('docker'))(get_docker_commands) | ||||||
|  |  | ||||||
|  |  | ||||||
| @sudo_support | @sudo_support | ||||||
| def get_new_command(command): | def get_new_command(command): | ||||||
|     wrong_command = re.findall( |     wrong_command = re.findall( | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| import re | import re | ||||||
| import subprocess | import subprocess | ||||||
| from thefuck.utils import for_app, eager, replace_command | from thefuck.utils import for_app, eager, replace_command, cache, which | ||||||
|  |  | ||||||
|  |  | ||||||
| @for_app('gem') | @for_app('gem') | ||||||
| @@ -26,6 +26,10 @@ def _get_all_commands(): | |||||||
|             yield line.strip().split(' ')[0] |             yield line.strip().split(' ')[0] | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if which('gem'): | ||||||
|  |     _get_all_commands = cache(which('gem'))(_get_all_commands) | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_new_command(command): | def get_new_command(command): | ||||||
|     unknown_command = _get_unknown_command(command) |     unknown_command = _get_unknown_command(command) | ||||||
|     all_commands = _get_all_commands() |     all_commands = _get_all_commands() | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| import re | import re | ||||||
| from subprocess import Popen, PIPE | from subprocess import Popen, PIPE | ||||||
| from thefuck.utils import for_app, eager, get_closest | from thefuck.utils import for_app, eager, get_closest, cache | ||||||
|  |  | ||||||
| regex = re.compile(r'Warning: Task "(.*)" not found.') | regex = re.compile(r'Warning: Task "(.*)" not found.') | ||||||
|  |  | ||||||
| @@ -10,6 +10,7 @@ def match(command): | |||||||
|     return regex.findall(command.output) |     return regex.findall(command.output) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @cache('Gruntfile.js') | ||||||
| @eager | @eager | ||||||
| def _get_all_tasks(): | def _get_all_tasks(): | ||||||
|     proc = Popen(['grunt', '--help'], stdout=PIPE) |     proc = Popen(['grunt', '--help'], stdout=PIPE) | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| import re | import re | ||||||
| import subprocess | import subprocess | ||||||
| from thefuck.utils import replace_command, for_app | from thefuck.utils import replace_command, for_app, cache | ||||||
|  |  | ||||||
|  |  | ||||||
| @for_app('gulp') | @for_app('gulp') | ||||||
| @@ -8,6 +8,7 @@ def match(command): | |||||||
|     return 'is not in your gulpfile' in command.output |     return 'is not in your gulpfile' in command.output | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @cache('gulpfile.js') | ||||||
| def get_gulp_tasks(): | def get_gulp_tasks(): | ||||||
|     proc = subprocess.Popen(['gulp', '--tasks-simple'], |     proc = subprocess.Popen(['gulp', '--tasks-simple'], | ||||||
|                             stdout=subprocess.PIPE) |                             stdout=subprocess.PIPE) | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| import re | import re | ||||||
| from subprocess import Popen, PIPE | from subprocess import Popen, PIPE | ||||||
| from thefuck.utils import for_app, eager, replace_command, replace_argument | from thefuck.utils import (for_app, eager, replace_command, replace_argument, | ||||||
|  |                            cache, which) | ||||||
|  |  | ||||||
| regex = re.compile(r'error Command "(.*)" not found.') | regex = re.compile(r'error Command "(.*)" not found.') | ||||||
|  |  | ||||||
| @@ -28,6 +29,10 @@ def _get_all_tasks(): | |||||||
|             yield line.split(' ')[-1] |             yield line.split(' ')[-1] | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if which('yarn'): | ||||||
|  |     _get_all_tasks = cache(which('yarn'))(_get_all_tasks) | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_new_command(command): | def get_new_command(command): | ||||||
|     misspelled_task = regex.findall(command.output)[0] |     misspelled_task = regex.findall(command.output)[0] | ||||||
|     if misspelled_task in npm_commands: |     if misspelled_task in npm_commands: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user