mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-22 21:08:48 +00:00
#609: Use replace_command
in yarn_command_not_found
This commit is contained in:
parent
df5428c5e4
commit
02f3250d39
@ -108,4 +108,4 @@ def test_not_match(command):
|
|||||||
@pytest.mark.parametrize('command, result', [
|
@pytest.mark.parametrize('command, result', [
|
||||||
(Command('yarn whyy webpack', stderr=stderr('whyy')), 'yarn why webpack')])
|
(Command('yarn whyy webpack', stderr=stderr('whyy')), 'yarn why webpack')])
|
||||||
def test_get_new_command(command, result):
|
def test_get_new_command(command, result):
|
||||||
assert get_new_command(command) == result
|
assert get_new_command(command)[0] == result
|
||||||
|
@ -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, replace_command
|
||||||
|
|
||||||
regex = re.compile(r'error Command "(.*)" not found.')
|
regex = re.compile(r'error Command "(.*)" not found.')
|
||||||
|
|
||||||
@ -28,6 +28,4 @@ def _get_all_tasks():
|
|||||||
def get_new_command(command):
|
def get_new_command(command):
|
||||||
misspelled_task = regex.findall(command.stderr)[0]
|
misspelled_task = regex.findall(command.stderr)[0]
|
||||||
tasks = _get_all_tasks()
|
tasks = _get_all_tasks()
|
||||||
fixed = get_closest(misspelled_task, tasks)
|
return replace_command(command, misspelled_task, tasks)
|
||||||
return command.script.replace(' {}'.format(misspelled_task),
|
|
||||||
' {}'.format(fixed))
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user