MCPcopy Create free account
hub / github.com/nodejs/node / format_file

Function format_file

deps/v8/tools/v8_presubmit.py:160–183  ·  view source on GitHub ↗
(command)

Source from the content-addressed store, hash-verified

158
159def JSLintWorker(command):
160 def format_file(command):
161 try:
162 file_name = command[-1]
163 with open(file_name, "r") as file_handle:
164 contents = file_handle.read()
165
166 process = subprocess.Popen(command, stdout=PIPE, stderr=subprocess.PIPE)
167 output, err = process.communicate()
168 rc = process.returncode
169 if rc != 0:
170 sys.stdout.write("error code " + str(rc) + " running clang-format.\n")
171 return rc
172
173 if decode(output) != contents:
174 return 1
175
176 return 0
177 except KeyboardInterrupt:
178 process.kill()
179 except Exception:
180 print(
181 'Error running clang-format. Please make sure you have depot_tools' +
182 ' in your third_party directory. Lint check skipped.')
183 process.kill()
184
185 rc = format_file(command)
186 if rc == 1:

Callers 1

JSLintWorkerFunction · 0.85

Calls 7

strFunction · 0.85
killMethod · 0.80
decodeFunction · 0.70
printFunction · 0.70
openFunction · 0.50
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected