node-cc-runner
Client for Closure Compiler web runner.
Install
npm install cc-runner
Usage
const runner = ;const compiler = ; compilerstart { if err console; return; compilerstatus { console; }; compiler;};
Instantiation
Runner instance will automatically launch child process on first request (if jar
option is not false
) and kill after last response (after timeout
period).
Options
jar
- path to Closure Compiler web runner jar file (default: automatically downloadedcc-web-runner-standalone-1.0.8.jar
).url
- Closure Compiler web runner service URL to be used in API calls (default:http://127.0.0.1:8081/
).timeout
- timeout since last request after which web service is stopped (default:100ms
). Iftimeout
is0
, then web service is not stopped automatically.
const runner = ; // Custom Closure Compiler web runner buildconst customCCWJar = ; customCCWJarstatus { console; console;}; // If Closure Compiler web runner is not already listening// on 8080 port, start and stop methods will fail on this instance.// `jar: false` option is useful when Closure Compiler web runner// service is managed from outside of Node.js process,// e.g. is running on servlet container.const clientOnly = ;
start([callback])
Start Closure Compiler web runner service. Callback is called after the service started to listen for requests.
Callback arguments:
error
stop([callback])
Stop Closure Compiler web runner service.
status([options,] callback)
Options:
level
String - is of type CompilationLevel, compilation leveldebug
Boolean - whether to callsetDebugOptionsForCompilationLevel
typeBased
Boolean - whether to callsetTypeBasedOptimizationOptions
wrappedOutput
Boolean - whether to callsetWrappedOutputOptimizations
Callback arguments:
error
object
options
Object - is of type CompilerOptions, compiler optionscompilerVersions
String - Closure Compiler version
externs(callback)
Callback arguments:
error
object
externs
Array - is of type List<SourceFile>, array of extern files
compile(data, callback)
Data:
externs
Array -[{ fileName: String, code: String }]
, array of extern filessources
Array -[{ fileName: String, code: String }]
, array of source files to compileoptimizations
level
String - is of type CompilationLevel, compilation leveldebug
Boolean - whether to callsetDebugOptionsForCompilationLevel
typeBased
Boolean - whether to callsetTypeBasedOptimizationOptions
wrappedOutput
Boolean - whether to callsetWrappedOutputOptimizations
options
Object - is of type CompilerOptions, compiler options
Callback arguments:
error
object
result
Object - is of type Result, compilations resultssource
String - compiled sourcestatus
String - SUCCESS|ERRORmessage
String - error message if status is 'ERROR'exception
Object - is of type Throwable, occurred exception
License
ISC