Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
uglify-save-license
Advanced tools
Readme
A support module for UglifyJS to detect and preserve license comments
// Backbone.js 1.1.2
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
(function(root, factory) {
// Set up Backbone appropriately for the environment. Start with AMD.
if (typeof define === 'function' && define.amd) {
define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
//...
↓
// Backbone.js 1.1.2
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
!function(a,b){if("function"==typeof define&&define.amd)define(["underscore","jquery","exports"],function(c,d,e){a.Backbone=b(a,e,c,d)});else if("undefined"!=typeof exports){...
This module enables us to preserve license comments when using UglifyJS.
Even if the license statement is in multiple line comments, or the comment has no directive such as @license
and /*!
, this module keeps them readable.
Install with npm. (Make sure you have installed Node.)
npm install --save-dev uglify-save-license
First of all, load uglify-save-license
module.
var saveLicense = require('uglify-save-license');
Pass this module to the comments
option.
var result = UglifyJS.minify('file1.js', {
output: {
comments: saveLicense
}
});
Pass this module to the preserveComments
option.
grunt.initConfig({
uglify: {
my_target: {
options: {
preserveComments: saveLicense
},
src: ['src/app.js'],
dest: 'dest/app.min.js'
}
}
});
uglify-save-license checks each comment token of a JavaScript file. The comment will be regarded as a license statement and preserved after compression, if it meets at least one of the following requirements:
MIT
and Copyright
.uglify-example.js
)#!/usr/bin/env node
var UglifyJS = require('uglify-js'),
saveLicense = require('uglify-save-license');
var minified = UglifyJS.minify(process.argv[2], {
output: {
comments: saveLicense
}
}).code;
console.log(minified);
// First line
// (c) 2014 John <- contains '(c)'
// The previous line is preserved
// This line won't be preserved.
(function(win, doc) {
var str = 'Hello World! :' + doc.title;
// This line will not, too.
console.log(str);
}(window, document));
node uglify-example.js <target filename>
// First line
// (c) 2014 John <- contains '(c)'
// The previous line is preserved
!function(o,l){var n="Hello World! :"+l.title;console.log(n)}(window,document);
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.initConfig
uglify:
target:
options:
preserveComments: require 'uglify-save-license'
files: [
expand: true
flatten: true
cwd: 'path/to/src'
src: ['**/*.js']
dest: 'tmp/'
]
concat:
js:
src: ['tmp/*.js']
dest: 'path/to/build/app.js'
clean:
tmpdir: ['tmp']
grunt.registerTask 'default' ['uglify', 'concat', 'clean']
uglify-save-license is inspired by grunt-license-saver and I used it as reference. Thanks, kyo-ago.
Copyright (c) 2013 - 2014 Shinnosuke Watanabe
Licensed under the MIT license.
FAQs
License detector for UglifyJS
The npm package uglify-save-license receives a total of 82,933 weekly downloads. As such, uglify-save-license popularity was classified as popular.
We found that uglify-save-license demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.