Extend yarn_alias rule to handle package.json scripts

For example, if an "etl" script is defined in package.json, it can be
run with `yarn etl`. However, if `yarn etil` is run, `yarn` will
suggest the correction. This change lets `thefuck` take advantage of
that:

    $ yarn etil
    yarn etil v0.21.3
    error Command "etil" not found. Did you mean "etl"?
    $ fuck
    yarn etl [enter/?/?/ctrl+c]
This commit is contained in:
Joseph Frazier
2017-03-22 16:50:08 -04:00
parent 1aaaca1220
commit bf109ee548
2 changed files with 4 additions and 2 deletions
+1 -1
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)