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

Merge pull request #619 from josephfrazier/yarn-alias-scripts

Extend yarn_alias rule to handle package.json scripts
This commit is contained in:
Vladimir Iakovlev 2017-03-23 19:39:11 +04:00 committed by GitHub
commit b016bb2255
2 changed files with 4 additions and 2 deletions

View File

@ -4,12 +4,13 @@ from tests.utils import Command
stderr_remove = 'error Did you mean `yarn remove`?'
stderr_etl = 'error Command "etil" not found. Did you mean "etl"?'
stderr_list = 'error Did you mean `yarn list`?'
@pytest.mark.parametrize('command', [
Command(script='yarn rm', stderr=stderr_remove),
Command(script='yarn etil', stderr=stderr_etl),
Command(script='yarn ls', stderr=stderr_list)])
def test_match(command):
assert match(command)
@ -17,6 +18,7 @@ def test_match(command):
@pytest.mark.parametrize('command, new_command', [
(Command('yarn rm', stderr=stderr_remove), 'yarn remove'),
(Command('yarn etil', stderr=stderr_etl), 'yarn etl'),
(Command('yarn ls', stderr=stderr_list), 'yarn list')])
def test_get_new_command(command, new_command):
assert get_new_command(command) == new_command

View File

@ -9,6 +9,6 @@ def match(command):
def get_new_command(command):
broken = command.script_parts[1]
fix = re.findall(r'Did you mean `yarn ([^`]*)`', command.stderr)[0]
fix = re.findall(r'Did you mean [`"](?:yarn )?([^`"]*)[`"]', command.stderr)[0]
return replace_argument(command.script, broken, fix)