def __init__(self, lib_path=None, use_nodejs_if_available=True): self._js_lint_proc_args = None self._module_path = os.path.dirname(os.path.realpath(__file__)) self._lib_path = lib_path or os.path.join(self._module_path, 'lib') self._jslint_script_regex = re.compile(r'^jslint.*\.js$') self._js_lint_script_file_path = first_file_name_in_path_matching_regex(self._lib_path, self._jslint_script_regex) self._rhino_jar_regex = re.compile(r'^js\.jar$') self._rhino_jar_file_path = first_file_name_in_path_matching_regex(self._lib_path, self._rhino_jar_regex) self._lib_message_list = [] if self._js_lint_proc_args is None and platform.system() == 'Windows': # Windows Script Host has two versions, wscript.exe which pops up # a window and cscript.exe which does not. self._js_lint_proc_args = ["cscript.exe", "//I", "//Nologo", self._js_lint_script_file_path] self._lib_message_list.append("Using cscript.exe to run JSLint") if self._js_lint_proc_args is None and use_nodejs_if_available: null_file = open(os.devnull, 'w') try: subprocess.check_call(['node', '--help'], stdout=null_file, stderr=null_file) self._js_lint_proc_args = ["node", self._js_lint_script_file_path] self._lib_message_list.append("Using node.js to run JSLint") except Exception: self._lib_message_list.append("Cannot use node.js to run JSLint because it was not found on the PATH") finally: null_file.close() if self._js_lint_proc_args is None: if self._rhino_jar_file_path: self._js_lint_proc_args = ["java", "-jar", self._rhino_jar_file_path, self._js_lint_script_file_path] self._lib_message_list.append("Using Rhino to run JSLint") else: self._lib_message_list.append("Cannot use Rhino to run JSLint because js.jar could not be found in in %r" % self._lib_path)
def __init__(self, options=None): self._options = options or {} self._js_lint_proc_args = None self._module_path = os.path.dirname(os.path.realpath(__file__)) self._lib_path = self._options.get( 'lib_path', os.path.join(self._module_path, 'lib')) self._jslint_script_regex = re.compile(r'^jslint.*\.js$') self._js_lint_script_file_path = first_file_name_in_path_matching_regex( self._lib_path, self._jslint_script_regex) self._rhino_jar_regex = re.compile(r'^js\.jar$') self._rhino_jar_file_path = first_file_name_in_path_matching_regex( self._lib_path, self._rhino_jar_regex) self._lib_message_list = [] self._use_nodejs_if_available = self._options.get( 'use_nodejs_if_available', True) if self._js_lint_proc_args is None and platform.system() == 'Windows': # Windows Script Host has two versions, wscript.exe which pops up # a window and cscript.exe which does not. self._js_lint_proc_args = [ "cscript.exe", "//I", "//Nologo", self._js_lint_script_file_path ] self._lib_message_list.append("Using cscript.exe to run JSLint") if self._js_lint_proc_args is None and self._use_nodejs_if_available: null_file = open(os.devnull, 'w') try: subprocess.check_call(['node', '--help'], stdout=null_file, stderr=null_file) self._js_lint_proc_args = [ "node", self._js_lint_script_file_path ] self._lib_message_list.append("Using node.js to run JSLint") except Exception: self._lib_message_list.append( "Cannot use node.js to run JSLint because it was not found on the PATH" ) finally: null_file.close() if self._js_lint_proc_args is None: if self._rhino_jar_file_path: self._js_lint_proc_args = [ "java", "-jar", self._rhino_jar_file_path, self._js_lint_script_file_path ] self._lib_message_list.append("Using Rhino to run JSLint") else: self._lib_message_list.append( "Cannot use Rhino to run JSLint because js.jar could not be found in in %r" % self._lib_path)
def __init__(self, options=None): self._options = options or {} self._yuic_proc_args = None self._module_path = os.path.dirname(os.path.realpath(__file__)) self._lib_path = self._options.get('lib_path', os.path.join(self._module_path, 'lib')) self._yuic_jar_regex = re.compile(r'^yuicompressor.*\.jar$') self._yuic_jar_file_path = first_file_name_in_path_matching_regex(self._lib_path, self._yuic_jar_regex)