CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-uglify-save-license

License detector for UglifyJS that identifies and preserves license comments during minification

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-5/

Multi-File JavaScript Minifier

Build a command-line tool that minifies multiple JavaScript files while preserving license comments across batch processing.

Requirements

Your tool should:

  1. Accept a list of input JavaScript file paths and corresponding output file paths as command-line arguments
  2. Read and minify each JavaScript file using UglifyJS
  3. Preserve license-related comments during minification (such as comments containing copyright notices, license types like MIT/BSD/GPL, or license-preservation directives)
  4. Handle multiple files in a single execution, ensuring that license detection state is properly managed across file boundaries
  5. Write the minified content to the corresponding output files

The tool should be invoked as:

node minifier.js <input1> <output1> <input2> <output2> ...

For example:

node minifier.js src/lib1.js dist/lib1.min.js src/lib2.js dist/lib2.min.js

@generates

Test Cases

  • Given two JavaScript files with license headers, when processing them in batch, both output files should preserve their respective license comments @test

  • Given a file with a multi-line license comment followed by code, and another file with a single-line license, when processing them sequentially, each output should preserve only its own license comments @test

  • Given a file with no license and a file with a license on line 1, when processing them in order, the second file's license should be preserved @test

Dependencies { .dependencies }

uglify-js { .dependency }

Provides JavaScript minification functionality.

uglify-save-license { .dependency }

Provides license comment detection and preservation during minification.

Install with Tessl CLI

npx tessl i tessl/npm-uglify-save-license

tile.json