gulp-uglify
Advanced tools
Comparing version 1.3.0 to 1.4.0
# gulp-uglify changelog | ||
## 1.4.0 | ||
- Deprecated the `preserveComments` option of "some". | ||
- Added the `preserveComments` option of "license" that uses [`uglify-save-license`](https://github.com/shinnn/uglify-save-license). | ||
## 1.3.0 | ||
- Updated UglifyJS to 2.4.24. | ||
- Streams3 support via through2 dependency update. | ||
## 1.2.0 | ||
@@ -4,0 +14,0 @@ |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var applySourceMap = require('vinyl-sourcemaps-apply'); | ||
var saveLicense = require('uglify-save-license'); | ||
var reSourceMapComment = /\n\/\/# sourceMappingURL=.+?$/; | ||
@@ -29,2 +30,4 @@ var pluginName = 'gulp-uglify'; | ||
options.output.comments = /^!|@preserve|@license|@cc_on/i; | ||
} else if (options.preserveComments === 'license') { | ||
options.output.comments = saveLicense | ||
} else if (typeof options.preserveComments === 'function') { | ||
@@ -31,0 +34,0 @@ options.output.comments = options.preserveComments; |
{ | ||
"name": "gulp-uglify", | ||
"description": "Minify files with UglifyJS.", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"author": "Terin Stock <terinjokes@gmail.com>", | ||
@@ -12,2 +12,3 @@ "bugs": "https://github.com/terinjokes/gulp-uglify/issues", | ||
"uglify-js": "2.4.24", | ||
"uglify-save-license": ">=0.4.1 <0.5.0-0", | ||
"vinyl-sourcemaps-apply": ">=0.1.1 <0.2.0-0" | ||
@@ -14,0 +15,0 @@ }, |
@@ -50,7 +50,15 @@ # gulp-uglify [![Build Status](http://img.shields.io/travis/terinjokes/gulp-uglify.svg?style=flat)](https://travis-ci.org/terinjokes/gulp-uglify) [![](http://img.shields.io/npm/dm/gulp-uglify.svg?style=flat)](https://www.npmjs.org/package/gulp-uglify) [![](http://img.shields.io/npm/v/gulp-uglify.svg?style=flat)](https://www.npmjs.org/package/gulp-uglify) [![](http://img.shields.io/codeclimate/github/terinjokes/gulp-uglify.svg?style=flat)](https://codeclimate.com/github/terinjokes/gulp-uglify) [![](http://img.shields.io/codeclimate/coverage/github/terinjokes/gulp-uglify.svg?style=flat)](https://codeclimate.com/github/terinjokes/gulp-uglify) | ||
- `some` | ||
- `license` | ||
Preserve comments that start with a bang (`!`) or include a Closure | ||
Compiler directive (`@preserve`, `@license`, `@cc_on`) | ||
Attempts to preserve comments that likely contain licensing information, | ||
even if the comment does not have directives such as `@license` or `/*!`. | ||
Implemented via the [`uglify-save-license`](https://github.com/shinnn/uglify-save-license) | ||
module, this option preserves a comment if one of the following is true: | ||
1. The comment is in the *first* line of a file | ||
2. A regular expression matches the string of the comment. | ||
For example: `MIT`, `@license`, or `Copyright`. | ||
3. There is a comment at the *previous* line, and it matches 1, 2, or 3. | ||
- `function` | ||
@@ -62,2 +70,8 @@ | ||
- `some` (deprecated) | ||
Preserve comments that start with a bang (`!`) or include a Closure Compiler | ||
directive (`@preserve`, `@license`, `@cc_on`). | ||
Deprecated in favor of the `license` option, documented above. | ||
You can also pass the `uglify` function any of the options [listed | ||
@@ -77,2 +91,2 @@ here](https://github.com/mishoo/UglifyJS2#the-simple-way) to modify | ||
To handle errors across your entire pipeline, see the | ||
[gulp](https://github.com/gulpjs/gulp/blob/master/docs/recipes/combining-streams-to-handle-errors.md#combining-streams-to-handle-errors) documentation. | ||
[gulp](https://github.com/gulpjs/gulp/blob/master/docs/recipes/combining-streams-to-handle-errors.md#combining-streams-to-handle-errors) documentation. |
@@ -30,3 +30,3 @@ 'use strict'; | ||
test('should preserve important comments', function(t) { | ||
test('should preserve some comments', function(t) { | ||
t.plan(3); | ||
@@ -54,2 +54,25 @@ | ||
test('should preserve license comments', function(t) { | ||
t.plan(3); | ||
var testFile1 = new Vinyl({ | ||
cwd: "/home/terin/broken-promises/", | ||
base: "/home/terin/broken-promises/test", | ||
path: "/home/terin/broken-promises/test/test1.js", | ||
contents: new Buffer('"use strict";\nfunction foobar(){}\n/* comment one */\n/* comment two MIT */\nfunction itsatrap(){}\n/* comment three */') | ||
}); | ||
var stream = gulpUglify({ preserveComments: 'license' }); | ||
stream.on('data', function(newFile) { | ||
var contents = newFile.contents.toString(); | ||
t.false(/one/.test(contents), 'does not have comment one'); | ||
t.ok(/two/.test(contents), 'has comment two'); | ||
t.false(/three/.test(contents), 'does not have comment three'); | ||
}); | ||
stream.write(testFile1); | ||
stream.end(); | ||
}); | ||
test('should preserve comments that fn returns true for', function(t) { | ||
@@ -56,0 +79,0 @@ t.plan(3); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61237
516
90
6
+ Addeduglify-save-license@0.4.1(transitive)