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..505ebc7531d982f08bec2538aa934512684e5242 100755 |
--- a/chrome/browser/resources/vulcanize_gn.py |
+++ b/chrome/browser/resources/vulcanize_gn.py |
@@ -172,9 +172,20 @@ def _vulcanize(in_folder, args): |
if not os.path.isfile(js_out_path): |
open(js_out_path, 'w').close() |
- node.RunNode([node_modules.PathToUglifyJs(), js_out_path, |
- '--comments', '"/Copyright|license|LICENSE|\<\/?if/"', |
- '--output', js_out_path]) |
+ # Rewrite licenses such that Closure Compiler will preserve them. |
+ import rewrite_licenses |
+ with open(js_out_path, 'r') as f: |
+ output_data = rewrite_licenses.rewrite(f.read()) |
+ |
+ # Open file again with 'w' such that the previous contents are overwritten. |
+ with open(js_out_path, 'w') as f: |
+ f.write(output_data) |
+ f.close() |
+ |
+ output = node.RunNode([node_modules.PathToClosureCompiler(), js_out_path]) |
+ with open(js_out_path, 'w') as output_file: |
+ output_file.write(output) |
+ |
finally: |
os.remove(tmp.name) |