1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-22 12:58:33 +00:00

#N/A: Cache docker, gem, grunt and yarn output in rules

This commit is contained in:
Vladimir Iakovlev 2017-09-02 10:22:00 +02:00
parent f20e344663
commit bf0867967b
5 changed files with 20 additions and 5 deletions

View File

@ -1,7 +1,7 @@
from itertools import dropwhile, takewhile, islice
import re
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
@ -20,6 +20,10 @@ def get_docker_commands():
return [line.strip().split(' ')[0] for line in lines]
if which('docker'):
get_docker_commands = cache(which('docker'))(get_docker_commands)
@sudo_support
def get_new_command(command):
wrong_command = re.findall(

View File

@ -1,6 +1,6 @@
import re
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')
@ -26,6 +26,10 @@ def _get_all_commands():
yield line.strip().split(' ')[0]
if which('gem'):
_get_all_commands = cache(which('gem'))(_get_all_commands)
def get_new_command(command):
unknown_command = _get_unknown_command(command)
all_commands = _get_all_commands()

View File

@ -1,6 +1,6 @@
import re
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.')
@ -10,6 +10,7 @@ def match(command):
return regex.findall(command.output)
@cache('Gruntfile.js')
@eager
def _get_all_tasks():
proc = Popen(['grunt', '--help'], stdout=PIPE)

View File

@ -1,6 +1,6 @@
import re
import subprocess
from thefuck.utils import replace_command, for_app
from thefuck.utils import replace_command, for_app, cache
@for_app('gulp')
@ -8,6 +8,7 @@ def match(command):
return 'is not in your gulpfile' in command.output
@cache('gulpfile.js')
def get_gulp_tasks():
proc = subprocess.Popen(['gulp', '--tasks-simple'],
stdout=subprocess.PIPE)

View File

@ -1,6 +1,7 @@
import re
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.')
@ -28,6 +29,10 @@ def _get_all_tasks():
yield line.split(' ')[-1]
if which('yarn'):
_get_all_tasks = cache(which('yarn'))(_get_all_tasks)
def get_new_command(command):
misspelled_task = regex.findall(command.output)[0]
if misspelled_task in npm_commands: