yui / yuicompressor

YUI Compressor
http://yui.github.com/yuicompressor/
Other
3.01k stars 662 forks source link

File not found when use absolute path #321

Open moonknight37 opened 5 years ago

moonknight37 commented 5 years ago

I tried to use the compressor as "java -jar E:/yuicompressor-2.4.8.jar --type js --charset UTF-8 E:/tmp/src/my.js -o E:/tmp/src/my.min.js" . When run the command, I got an error like "java.io.FileNotFoundException: \tmp\src\my.min.js:\tmp\src\my.js". The full stack is: java.io.FileNotFoundException: \tmp\src\my.min.js:\tmp\src\my.js at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(FileOutputStream.java:270) at java.io.FileOutputStream.(FileOutputStream.java:213) at java.io.FileOutputStream.(FileOutputStream.java:101) at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:204)

moonknight37 commented 5 years ago

I found a comment in class named YUICompressor, line number 159. Code is: // if a substitution pattern was passed in if (pattern.length > 1 && files.size() > 0) { outputFilename = inputFilename.replaceFirst(pattern[0], pattern[1]); } The code block replaced the absolute path .

TimLethbridge commented 5 years ago

The workaround is to send the output to standard output and redirect it to a file. We had this problem and it worked for us.