Chromium Code Reviews| Index: third_party/polymer/v1_0/find_unused_elements.py |
| diff --git a/third_party/polymer/v1_0/find_unused_elements.py b/third_party/polymer/v1_0/find_unused_elements.py |
| index 5dbacdbdcbcec33a1c587eb987f182fc234e3025..bc377c1c1d8ec03dceefd8f19de026f5a57b428c 100644 |
| --- a/third_party/polymer/v1_0/find_unused_elements.py |
| +++ b/third_party/polymer/v1_0/find_unused_elements.py |
| @@ -11,7 +11,14 @@ to check if other elements have become unused. |
| import os |
| import re |
| import subprocess |
| +import sys |
| +import tempfile |
| +_HERE_PATH = os.path.dirname(__file__) |
| +_SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..')) |
| +sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'node')) |
|
michaelpg
2017/06/05 19:22:36
remove uglify check in reproduce.sh
dpapad
2017/06/05 19:42:02
Done.
|
| +import node |
| +import node_modules |
| class UnusedElementsDetector(object): |
| """Finds unused Polymer elements.""" |
| @@ -58,8 +65,16 @@ class UnusedElementsDetector(object): |
| text = re.sub('<if .*?>', '', text, flags=re.IGNORECASE) |
| text = re.sub('</if>', '', text, flags=re.IGNORECASE) |
| - proc = subprocess.Popen(['uglifyjs', filename], stdout=subprocess.PIPE) |
|
Dan Beam
2017/06/02 21:49:08
can we change to subprocess2 and use stderr=subpro
dpapad
2017/06/05 19:22:09
We probably could (have not tried yet), but import
dpapad
2017/06/06 21:39:55
This is not necessary anymore. I rebased this CL a
|
| - return proc.stdout.read() |
| + # Need to write the output to a temporary file to avoid |
| + # https://github.com/mishoo/UglifyJS2/issues/641 which has been fixed after |
| + # version 2.4.21. |
| + # TODO(dpapad): Chromium currently uses 2.4.10, update to latest version. |
| + with tempfile.NamedTemporaryFile(mode='wt+') as tmp: |
| + node.RunNode([ |
| + node_modules.PathToUglifyJs(), filename, '--output', tmp.name]) |
| + output = tmp.read() |
| + |
| + return output |
| @staticmethod |
| def __StripComments(filename): |
| @@ -133,11 +148,6 @@ class UnusedElementsDetector(object): |
| if not filename.endswith('.html') and not filename.endswith('.js'): |
| continue |
| - # Skip generated files that may include the element source. |
| - if filename in ('crisper.js', 'vulcanized.html', |
| - 'app.crisper.js', 'app.vulcanized.html'): |
| - continue |
| - |
| with open(os.path.join(dirpath, filename)) as f: |
| text = f.read() |
| if not re.search('/%s/' % element_dir, text): |