#N/A Add gulp_not_task rule

This commit is contained in:
nvbn
2015-07-24 00:47:57 +03:00
parent 469c5a60b0
commit b15bc8c423
3 changed files with 51 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import re
import subprocess
from thefuck.utils import get_closest, replace_argument
def match(command, script):
return command.script.startswith('gulp')\
and 'is not in your gulpfile' in command.stdout
def get_gulp_tasks():
proc = subprocess.Popen(['gulp', '--tasks-simple'],
stdout=subprocess.PIPE)
return [line.decode('utf-8')[:-1]
for line in proc.stdout.readlines()]
def get_new_command(command, script):
wrong_task = re.findall(r"Task '(\w+)' is not in your gulpfile",
command.stdout)[0]
fixed_task = get_closest(wrong_task, get_gulp_tasks())
return replace_argument(command.script, wrong_task, fixed_task)