Commit 27ecbce2 authored by dpapad's avatar dpapad Committed by Commit Bot

Closure compiler: Delete unused js_minify.py script.

This script was previously used with Grit, but that is no longer
the case since r682948.

Bug: None
Change-Id: I67446b17949c16493963d307f89e91ec43b06a89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2222765
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773377}
parent d7f09f66
#!/usr/bin/env python
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
''' Javascript minifier using the closure compiler
This minifier strips spaces and comments out of Javascript using the closure
compiler. It takes the original Javascript on standard input, and outputs
the minified output on standard output.
Any errors or other messages from the compiler are output on standard error.
'''
import argparse
import sys
import tempfile
from compiler import Compiler
def Minify(source):
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--closure_args", nargs=argparse.ZERO_OR_MORE,
help="Arguments passed directly to the Closure compiler")
args = parser.parse_args()
with tempfile.NamedTemporaryFile(suffix='.js') as t1, \
tempfile.NamedTemporaryFile(suffix='.js') as t2:
t1.write(source)
t1.seek(0)
(compile_error, compile_stderr) = Compiler().run(
[t1.name],
out_file=t2.name,
closure_args=args.closure_args)
if compile_error:
print compile_stderr
t2.seek(0)
result = t2.read()
return result
if __name__ == '__main__':
orig_stdout = sys.stdout
result = ''
try:
sys.stdout = sys.stderr
result = Minify(sys.stdin.read())
finally:
sys.stdout = orig_stdout
print result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment