Merge 9496382b63 into 62e0767c50
This commit is contained in:
commit
58cb3522df
|
|
@ -301,6 +301,7 @@ following rules are enabled by default:
|
|||
* `mkdir_p` – adds `-p` when you try to create a directory without a parent;
|
||||
* `mvn_no_command` – adds `clean package` to `mvn`;
|
||||
* `mvn_unknown_lifecycle_phase` – fixes misspelled life cycle phases with `mvn`;
|
||||
* `ninja` – fixes wrong targest passed to the `ninja` build tool;
|
||||
* `npm_missing_script` – fixes `npm` custom script name in `npm run-script <script>`;
|
||||
* `npm_run_script` – adds missing `run-script` for custom `npm` scripts;
|
||||
* `npm_wrong_command` – fixes wrong npm commands like `npm urgrade`;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import pytest
|
||||
from thefuck.rules.ninja import get_new_command, match
|
||||
from thefuck.types import Command
|
||||
|
||||
match_output = 'ninja: error: unknown target \'clong\', did you mean \'clang\'?'
|
||||
no_match_output = 'ninja: error: unknown target \'foobar\''
|
||||
|
||||
def test_match():
|
||||
assert match(Command('ninja clong', match_output))
|
||||
assert not match(Command('ninja foobar', no_match_output))
|
||||
|
||||
def test_get_new_command():
|
||||
new_command = get_new_command(Command('ninja clong', match_output))
|
||||
assert new_command == 'ninja clang'
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import re
|
||||
|
||||
def match(command):
|
||||
return 'unknown target' in command.output and 'did you mean' in command.output
|
||||
|
||||
def get_new_command(command):
|
||||
target = re.search(r'did you mean \'(.*)\'\?$', command.output).group(1)
|
||||
return 'ninja {}'.format(target)
|
||||
Loading…
Reference in New Issue