Last active
February 13, 2019 17:11
-
-
Save blech/6134afe2c00efc28b60dd22ed9c41a1a to your computer and use it in GitHub Desktop.
BBEdit script to run `eslint --fix` on the current file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
from copy import copy | |
from subprocess import run | |
from warnings import warn | |
doc_location = os.environ.get('BB_DOC_PATH', None) | |
if not doc_location.endswith('.js'): | |
sys.exit(0) | |
# extract path to project root | |
offset = doc_location.find('packages') | |
project_location = doc_location[0:offset] | |
# eslint lives at ./node_modules/eslint/bin/eslint.js | |
resp = run( | |
[ | |
f"{project_location}node_modules/eslint/bin/eslint.js", | |
"--fix", | |
doc_location, | |
], | |
capture_output=True | |
) | |
sys.exit(resp.returncode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment