Index: chrome/browser/resources/vulcanize_gn.py |
diff --git a/chrome/browser/resources/vulcanize_gn.py b/chrome/browser/resources/vulcanize_gn.py |
index 309ab32be4bb53533003a2116b68bdb96f1cee12..57b51c3b88e27bda0281714f1c53f2ec788f02fa 100755 |
--- a/chrome/browser/resources/vulcanize_gn.py |
+++ b/chrome/browser/resources/vulcanize_gn.py |
@@ -158,25 +158,27 @@ def _vulcanize(in_folder, args): |
# that by adding a <base> tag to the (post-processed) generated output. |
output = output.replace('<head>', '<head>' + args.insert_in_head) |
- with tempfile.NamedTemporaryFile(mode='wt+', delete=False) as tmp: |
- tmp.write(output) |
+ with tempfile.NamedTemporaryFile( |
+ mode='wt+', delete=False) as tmp_crisper_input: |
+ tmp_crisper_input.write(output) |
Dan Beam
2017/06/03 01:19:05
nit:
crisper_input = tempfile.NamedTemporaryFile(
dpapad
2017/06/03 01:27:10
Done.
|
+ |
+ tmp_crisper_output = tempfile.NamedTemporaryFile(mode='wt+', delete=False) |
try: |
node.RunNode([node_modules.PathToCrisper(), |
- '--source', tmp.name, |
+ '--source', tmp_crisper_input.name, |
'--script-in-head', 'false', |
'--html', html_out_path, |
- '--js', js_out_path]) |
- |
- # Create an empty JS file if crisper did not create one. |
- if not os.path.isfile(js_out_path): |
- open(js_out_path, 'w').close() |
+ '--js', tmp_crisper_output.name]) |
- node.RunNode([node_modules.PathToUglifyJs(), js_out_path, |
+ node.RunNode([node_modules.PathToUglifyJs(), tmp_crisper_output.name, |
'--comments', '"/Copyright|license|LICENSE|\<\/?if/"', |
'--output', js_out_path]) |
finally: |
- os.remove(tmp.name) |
+ if os.path.exists(tmp_crisper_input.name): |
+ os.remove(tmp_crisper_input.name) |
+ if os.path.exists(tmp_crisper_output.name): |
+ os.remove(tmp_crisper_output.name) |
def main(argv): |