eslint.py 827 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. # Copyright 2019 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. def Run(os_path=None, args=None):
  6. try:
  7. _HERE_PATH = os_path.dirname(os_path.realpath(__file__))
  8. _SRC_PATH = os_path.normpath(os_path.join(_HERE_PATH, '..', '..'))
  9. _NODE_PATH = os_path.join(_SRC_PATH, 'third_party', 'node')
  10. import sys
  11. old_sys_path = sys.path[:]
  12. sys.path.append(_NODE_PATH)
  13. import node, node_modules
  14. finally:
  15. sys.path = old_sys_path
  16. return node.RunNode([
  17. node_modules.PathToEsLint(),
  18. '--resolve-plugins-relative-to',
  19. os_path.join(_NODE_PATH, 'node_modules'),
  20. ] + args)
  21. if __name__ == '__main__':
  22. import os
  23. import sys
  24. Run(os_path=os.path, args=sys.argv[1:])