-
Notifications
You must be signed in to change notification settings - Fork 3
/
nglint.py
executable file
·34 lines (29 loc) · 1.09 KB
/
nglint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
import os
import sys
def main(argv=None):
'''
Handle various pre-commit config options:
- args:
- if set, a bare double-dash is needed to distinguish options from the list of filenames
- args before '--' are lint options and args after '--' are filenames
- pass_filenames:
- if false, ng lint should run over the full project
'''
cmd = ['ng', 'lint'] # If no args, run ng lint over the whole project
if len(sys.argv) > 1: # sys.argv => command + args; length >= 1
if '--' in sys.argv:
# argv items before '--' are lint options
bare_dd_index = sys.argv.index('--')
cmd = cmd + sys.argv[1:bare_dd_index]
# argv items after '--' are filenames (if provided)
filenames = sys.argv[bare_dd_index+1:]
if len(filenames):
cmd += ['--files'] + filenames
else:
# argv items are the filenames
cmd = (cmd + ['--files'] + sys.argv[1:])
print(cmd)
os.execvp(cmd[0], cmd)
if __name__ == '__main__':
exit(main())