07-24-2023, 07:22 AM
I am trying to automate compression of multiple JS/CSS files with the [YUI Compressor][1]. Each time I basically need to run the following Java command:
> java -jar yuicompressor-2.4.8.jar "script in.js" -o "script out.js"
So I do it using Microsoft's JScript engine:
var oShell = WScript.CreateObject("WScript.Shell");
var scriptIn = "script in.js";
var scriptOut = "script out.js";
var strRun = "java -jar yuicompressor-2.4.8.jar \"" + scriptIn + "\" -o \"" + scriptOut + "\"";
oShell.Run(strRun, 0, true);
This works fine, except that it doesn't give me any output from the compressor. Note that if I put that same line of Java code in a .bat file and run it from a command line, it gives me the output from running the command (YUI Compressor's warnings, errors, etc.)
So I'm curious, how do I collect it via my JScript?
[1]:
> java -jar yuicompressor-2.4.8.jar "script in.js" -o "script out.js"
So I do it using Microsoft's JScript engine:
var oShell = WScript.CreateObject("WScript.Shell");
var scriptIn = "script in.js";
var scriptOut = "script out.js";
var strRun = "java -jar yuicompressor-2.4.8.jar \"" + scriptIn + "\" -o \"" + scriptOut + "\"";
oShell.Run(strRun, 0, true);
This works fine, except that it doesn't give me any output from the compressor. Note that if I put that same line of Java code in a .bat file and run it from a command line, it gives me the output from running the command (YUI Compressor's warnings, errors, etc.)
So I'm curious, how do I collect it via my JScript?
[1]:
[To see links please register here]