Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2456)

Unified Diff: chrome/browser/resources/vulcanize_gn.py

Issue 2915393002: vulcanize_gn.py: Stop writing twice to the declared GN output file. (Closed)
Patch Set: Nit. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..47d4421d98b8db869ba8587b13fb4a4b9abb80e3 100755
--- a/chrome/browser/resources/vulcanize_gn.py
+++ b/chrome/browser/resources/vulcanize_gn.py
@@ -158,25 +158,28 @@ 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)
+ crisper_input = tempfile.NamedTemporaryFile(mode='wt+', delete=False)
+ crisper_input.write(output)
+ crisper_input.close()
+
+ crisper_output = tempfile.NamedTemporaryFile(mode='wt+', delete=False)
+ crisper_output.close()
try:
node.RunNode([node_modules.PathToCrisper(),
- '--source', tmp.name,
+ '--source', 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', crisper_output.name])
dpapad 2017/06/05 19:46:07 So this is causing a problem. Crisper substitutes
dpapad 2017/06/05 22:12:11 PTAL. I fixed this in patch#4 using approach #2 ab
- node.RunNode([node_modules.PathToUglifyJs(), js_out_path,
+ node.RunNode([node_modules.PathToUglifyJs(), crisper_output.name,
'--comments', '"/Copyright|license|LICENSE|\<\/?if/"',
'--output', js_out_path])
finally:
- os.remove(tmp.name)
+ if os.path.exists(crisper_input.name):
+ os.remove(crisper_input.name)
+ if os.path.exists(crisper_output.name):
+ os.remove(crisper_output.name)
def main(argv):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698