#N/A: Add npm_missing_script rule

This commit is contained in:
Vladimir Iakovlev
2016-08-13 18:28:45 +03:00
parent b09a4e394e
commit fdfbfc80c0
8 changed files with 141 additions and 18 deletions
+21
View File
@@ -0,0 +1,21 @@
import re
from subprocess import Popen, PIPE
from thefuck.utils import memoize, eager, which
npm_available = bool(which('npm'))
@memoize
@eager
def get_scripts():
"""Get custom npm scripts."""
proc = Popen(['npm', 'run-script'], stdout=PIPE)
should_yeild = False
for line in proc.stdout.readlines():
line = line.decode()
if 'available via `npm run-script`:' in line:
should_yeild = True
continue
if should_yeild and re.match(r'^ [^ ]+', line):
yield line.strip().split(' ')[0]