def run_script_on_file(self, data):
try:
dirname = os.path.dirname(data)
node_path = PluginUtils.get_node_path()
eslint_path = PluginUtils.get_eslint_path(dirname)
if eslint_path == False:
sublime.error_message('ESLint could not be found on your path')
return;
cmd = [node_path, eslint_path, '--fix', data]
config_path = PluginUtils.get_pref("config_path")
if os.path.isfile(config_path):
# If config file path exists, use as is
full_config_path = config_path
else:
# Find config gile relative to project path
project_path = PluginUtils.project_path()
full_config_path = os.path.join(project_path, config_path)
if os.path.isfile(full_config_path):
print("Using configuration from {0}".format(full_config_path))
cmd.extend(["--config", full_config_path])
if self.view.file_name():
cdir = os.path.dirname(self.view.file_name())
else:
cdir = "/"
output = PluginUtils.get_output(cmd, cdir, data)
return output;
except:
# Something bad happened.
msg = str(sys.exc_info()[1])
print("Unexpected error({0}): {1}".format(sys.exc_info()[0], msg))
sublime.error_message(msg)
评论列表
文章目录