MCPcopy Index your code
hub / github.com/nodejs/node / process

Function process

deps/v8/tools/torque/format-torque.py:154–189  ·  view source on GitHub ↗
(filename, lint, should_format)

Source from the content-addressed store, hash-verified

152 return output
153
154def process(filename, lint, should_format):
155 with open(filename, 'r') as content_file:
156 content = content_file.read()
157
158 original_input = content
159
160 style = {"BasedOnStyle": "Google", "NamespaceIndentation": "None"}
161
162 if sys.platform.startswith('win'):
163 p = Popen(
164 ['clang-format', '-assume-filename=.ts', '-style=' + json.dumps(style)],
165 stdin=PIPE,
166 stdout=PIPE,
167 stderr=PIPE,
168 shell=True)
169 else:
170 p = Popen(
171 ['clang-format', '-assume-filename=.ts', '-style=' + json.dumps(style)],
172 stdin=PIPE,
173 stdout=PIPE,
174 stderr=PIPE)
175 output, err = p.communicate(encode(preprocess(content)))
176 output = postprocess(decode(output))
177 rc = p.returncode
178 if (rc != 0):
179 print("error code " + str(rc) + " running clang-format. Exiting...")
180 sys.exit(rc);
181
182 if (output != original_input):
183 if lint:
184 print(filename + ' requires formatting', file=sys.stderr)
185
186 if should_format:
187 output_file = open(filename, 'wb')
188 output_file.write(encode(output))
189 output_file.close()
190
191def print_usage():
192 print('format-torque -i file1[, file2[, ...]]')

Callers 2

idlharness.jsFile · 0.85
MainFunction · 0.85

Calls 11

postprocessFunction · 0.85
strFunction · 0.85
encodeFunction · 0.70
preprocessFunction · 0.70
decodeFunction · 0.70
closeMethod · 0.65
openFunction · 0.50
printFunction · 0.50
readMethod · 0.45
exitMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected