mirror of
https://github.com/nvbn/thefuck.git
synced 2025-04-15 15:20:42 +01:00
Merge branch 'dfadev-master'
This commit is contained in:
commit
99c10b50ff
@ -259,6 +259,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
|
|||||||
* `workon_doesnt_exists` – fixes `virtualenvwrapper` env name os suggests to create new.
|
* `workon_doesnt_exists` – fixes `virtualenvwrapper` env name os suggests to create new.
|
||||||
* `yarn_alias` – fixes aliased `yarn` commands like `yarn ls`;
|
* `yarn_alias` – fixes aliased `yarn` commands like `yarn ls`;
|
||||||
* `yarn_command_not_found` – fixes misspelled `yarn` commands;
|
* `yarn_command_not_found` – fixes misspelled `yarn` commands;
|
||||||
|
* `yarn_command_replaced` – fixes replaced `yarn` commands;
|
||||||
* `yarn_help` – makes it easier to open `yarn` documentation;
|
* `yarn_help` – makes it easier to open `yarn` documentation;
|
||||||
|
|
||||||
Enabled by default only on specific platforms:
|
Enabled by default only on specific platforms:
|
||||||
|
32
tests/rules/test_yarn_command_replaced.py
Normal file
32
tests/rules/test_yarn_command_replaced.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import pytest
|
||||||
|
from tests.utils import Command
|
||||||
|
from thefuck.rules.yarn_command_replaced import match, get_new_command
|
||||||
|
|
||||||
|
|
||||||
|
stderr = ('error `install` has been replaced with `add` to add new '
|
||||||
|
'dependencies. Run "yarn add {}" instead.').format
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command', [
|
||||||
|
Command(script='yarn install redux', stderr=stderr('redux')),
|
||||||
|
Command(script='yarn install moment', stderr=stderr('moment')),
|
||||||
|
Command(script='yarn install lodash', stderr=stderr('lodash'))])
|
||||||
|
def test_match(command):
|
||||||
|
assert match(command)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command', [
|
||||||
|
Command('yarn install')])
|
||||||
|
def test_not_match(command):
|
||||||
|
assert not match(command)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
|
(Command('yarn install redux', stderr=stderr('redux')),
|
||||||
|
'yarn add redux'),
|
||||||
|
(Command('yarn install moment', stderr=stderr('moment')),
|
||||||
|
'yarn add moment'),
|
||||||
|
(Command('yarn install lodash', stderr=stderr('lodash')),
|
||||||
|
'yarn add lodash')])
|
||||||
|
def test_get_new_command(command, new_command):
|
||||||
|
assert get_new_command(command) == new_command
|
13
thefuck/rules/yarn_command_replaced.py
Normal file
13
thefuck/rules/yarn_command_replaced.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import re
|
||||||
|
from thefuck.utils import for_app
|
||||||
|
|
||||||
|
regex = re.compile(r'Run "(.*)" instead')
|
||||||
|
|
||||||
|
|
||||||
|
@for_app('yarn', at_least=1)
|
||||||
|
def match(command):
|
||||||
|
return regex.findall(command.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_command(command):
|
||||||
|
return regex.findall(command.stderr)[0]
|
Loading…
x
Reference in New Issue
Block a user