outputwrapper with a newline?

300 views
Skip to first unread message

bolinfest

unread,
Jun 20, 2010, 2:25:00 PM6/20/10
to Closure Compiler Discuss
I really want to pass something like the following to calcdeps.py:

-f "--output_wrapper=// Copyright 2010\n(function(){%output%})();"

The spirit of what I am trying to do is specify an output wrapper that
contains a newline. Between all the double-flag stuff and resultant
quoting, this is a real pain.

On top of that, I'm trying to use this from Ant, which then requires
an extra level of XML-escaping. The goal is to get something that
works cross-platform.

Any ideas?
Michael

bolinfest

unread,
Jun 20, 2010, 2:35:27 PM6/20/10
to Closure Compiler Discuss
Perhaps it would be a lot simpler to just a allow a special character
or sequence to represent a newline.

Bjorn Tipling

unread,
Jun 20, 2010, 2:37:01 PM6/20/10
to Closure Compiler Discuss
Why not just use ant to add the copyright line after the compilation
is finished?

Chad Killingsworth

unread,
Jun 21, 2010, 8:30:16 AM6/21/10
to Closure Compiler Discuss
Either way - I've bumped up against this as well. Would be handy.

Chad Killingsworth

Nick Santos

unread,
Jun 21, 2010, 12:25:58 PM6/21/10
to closure-comp...@googlegroups.com
would it be easier to just create Ant tasks for generating all these
things? Then you could remove escaping, rather than adding new
escaping :)

Chad Killingsworth

unread,
Jun 23, 2010, 5:57:04 PM6/23/10
to Closure Compiler Discuss
Only easier if I were using Ant :-)

Chad Killingsworth

bolinfest

unread,
Jun 24, 2010, 9:19:18 AM6/24/10
to Closure Compiler Discuss
Right, I would like to make this easier for everyone, not just those
who are using a particular tool.

Perhaps the command line runner should interpret "\n" as newline, as
per the principle of least surprise.

On Jun 23, 5:57 pm, Chad Killingsworth

Nick Santos

unread,
Jun 24, 2010, 9:30:51 AM6/24/10
to closure-comp...@googlegroups.com
On Thu, Jun 24, 2010 at 9:19 AM, bolinfest <boli...@gmail.com> wrote:
Right, I would like to make this easier for everyone, not just those
who are using a particular tool.

by the principle of least surprise, i would expect closure compiler to escape things consistently with every other command-line tool. :)

shouldn't it be the responsibility of the wrapping tool to offer better escape sequences (as many do)?

Nick

John Lenz

unread,
Jun 24, 2010, 11:42:11 AM6/24/10
to closure-comp...@googlegroups.com
I don't think it would be a big deal to add "%newline%" to the tokens that the compiler expands for the output wrapper if it makes life easier.

bolinfest

unread,
Jun 25, 2010, 1:29:21 AM6/25/10
to Closure Compiler Discuss
Unfortunately the bar for what is consistentcy with "every other
command line tool" is low/disappointing:

http://geekexplains.blogspot.com/2009/05/passing-n-new-line-on-command-line-in.html

I think having \n interpreted as a newline within the string is fairly
desirable. %newline% would work too, but is far less obvious.

On Jun 24, 9:30 am, Nick Santos <nicksan...@google.com> wrote:

Mike Samuel

unread,
Jun 25, 2010, 5:01:49 AM6/25/10
to closure-comp...@googlegroups.com
Most shells have no trouble with newlines in command line arguments.

Why not just fix calcdeps.py so the following command line works as expected?

-f '--output_wrapper="// Copyright 2010
(function(){%output%})();"'


2010/6/25 bolinfest <boli...@gmail.com>:

John Lenz

unread,
Jun 25, 2010, 10:44:46 AM6/25/10
to closure-comp...@googlegroups.com
The problem I have with "\n" is that it would require another level of escaping if you wanted it to be interpreted literally.  %output% is already a substitution.

Alexander Inkin

unread,
Apr 6, 2016, 11:02:04 AM4/6/16
to Closure Compiler Discuss
So, 6 years later I'm trying to minify all my JS files in IntelliJ Idea using Closure Compiler with source maps on windows and I'm facing the same issue. How do I add a new line? Literal \n symbols are just added into my JS which breaks it.

воскресенье, 20 июня 2010 г., 21:25:00 UTC+3 пользователь Michael Bolin написал:

calb...@stellarscience.com

unread,
Apr 8, 2016, 11:48:04 AM4/8/16
to Closure Compiler Discuss
The compiler now supports --output_wrapper_file, which I have used with great success to add arbitrary, un-escaped text.

Michael Zhou

unread,
Apr 8, 2016, 2:00:15 PM4/8/16
to Closure Compiler Discuss
I'm adding that flag to the help message in https://github.com/google/closure-compiler/pull/1716
Reply all
Reply to author
Forward
0 new messages