Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Limit the number of characters on a single line #3

Merged
merged 2 commits into from

2 participants

@sompylasar

UglifyJS gen_code does not call split_lines automatically.
The command-line tool calls it: https://github.com/mishoo/UglifyJS/blob/master/bin/uglifyjs#L316
In addition, removed the empty lines at the beginning of the compressed code (before the first preserved comment).

sompylasar added some commits
@sompylasar sompylasar lib/jsminify: Added uglify.split_lines call
UglifyJS `gen_code` does not call `split_lines` automatically.
The command-line tool calls it: https://github.com/mishoo/UglifyJS/blob/master/bin/uglifyjs#L316
ca8bd4e
@sompylasar sompylasar lib/jsminify: Reordered uglify.split_lines call to avoid empty line a…
…fter the preserved comments. Removed empty lines at the beginning.
770340e
@davglass davglass was assigned
@davglass
Owner

FYI, I'm not ignoring this I'm waiting until after the next YUI release to merge this so we don't have any min file changes ;)

@sompylasar

@davglass Thanks for the info. Looking forward to the merge. ;)

@davglass davglass merged commit 7da9ae0 into from
@davglass
Owner

Published in yuglify@0.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 27, 2012
  1. @sompylasar

    lib/jsminify: Added uglify.split_lines call

    sompylasar authored
    UglifyJS `gen_code` does not call `split_lines` automatically.
    The command-line tool calls it: https://github.com/mishoo/UglifyJS/blob/master/bin/uglifyjs#L316
  2. @sompylasar

    lib/jsminify: Reordered uglify.split_lines call to avoid empty line a…

    sompylasar authored
    …fter the preserved comments. Removed empty lines at the beginning.
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/jsminify.js
View
11 lib/jsminify.js
@@ -58,7 +58,12 @@ exports.jsminify = function (code, config, callback) {
code = uglify.gen_code(ast, config);
- //First pass with comma (comment inside code somewhere
+ //Limit the number of characters on a single line
+ if (!config.beautify && config.max_line_length) {
+ code = uglify.split_lines(code, config.max_line_length);
+ }
+
+ //First pass with comma (comment inside code somewhere)
code = code.replace(reTokens1, function () {
return '\n' + comments.shift() + '\n';
});
@@ -72,6 +77,10 @@ exports.jsminify = function (code, config, callback) {
(code.substr(code.length - 1) === '}')) {
code += ';';
}
+
+ //Trim spaces at the beginning of the code
+ code = code.replace(/^\s+/, '');
+
code += '\n';
callback(null, code);
Something went wrong with that request. Please try again.