npm.io
10.5.0 • Published 5 months ago

@node-minify/run

Licence
MIT
Version
10.5.0
Deps
0
Size
16 kB
Vulns
0
Weekly
0
Stars
520

node-minify

A very light minifier Node.js module.


npm version npm downloads Build Status code coverage

@node-minify/run

Command execution wrapper for Java-based compressors in node-minify.

This package provides utilities to spawn Java processes for compressors like YUI Compressor and Google Closure Compiler.

Installation

npm install @node-minify/run

Usage

import { runCommandLine } from '@node-minify/run';

const result = await runCommandLine({
  args: ['-jar', 'path/to/compiler.jar'],
  data: 'var foo = 1;'
});

console.log(result); // Minified output

API

runCommandLine(params)

Executes a Java command with the provided arguments and pipes data to stdin.

Parameters
Name Type Description
params.args string[] Command line arguments for the Java process
params.data string Content to minify (piped to stdin)
Returns

Promise<string> - The minified content from stdout.

Throws
  • Error if the Java process exits with a non-zero code
  • Error if there's a process spawn error

Requirements

  • Java Runtime Environment (JRE) must be installed and available in PATH

License

MIT

Keywords