Commit 981bb48d authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[tools] Format JS files in system-analyzer/ if they're unformatted

Instead of just warning, let's try to format the files as well

Bug: v8:10670
Change-Id: I0dfbdc0ed4a96af7f2a2a472f1d0d3d332d39c90
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2523193
Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Auto-Submit: Sathya Gunasekaran  <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71076}
parent a9252d70
......@@ -99,7 +99,7 @@ def _V8PresubmitChecks(input_api, output_api):
def FilterJSFile(affected_file):
return input_api.FilterSourceFile(
affected_file,
white_list=(r'.+\.m?js'))
files_to_check=(r'.+\.m?js'))
results = []
if not CppLintProcessor().RunOnFiles(
......
......@@ -132,6 +132,7 @@ def TorqueLintWorker(command):
process.kill()
def JSLintWorker(command):
def format_file(command):
try:
file_name = command[-1]
with open(file_name, "r") as file_handle:
......@@ -145,7 +146,6 @@ def JSLintWorker(command):
return rc
if output != contents:
sys.stdout.write(file_name + " requires formatting.\n")
return 1
return 0
......@@ -156,6 +156,14 @@ def JSLintWorker(command):
' in your $PATH. Lint check skipped.')
process.kill()
rc = format_file(command)
if rc == 1:
# There are files that need to be formatted, let's format them in place.
file_name = command[-1]
sys.stdout.write("Formatting %s.\n" % (file_name))
rc = format_file(command[:-1] + ["-i", file_name])
return rc
class FileContentsCache(object):
def __init__(self, sums_file_name):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment