K2JS: fix KT-5639 Exception in kotlin-js when directory is given instead of output file

#KT-5639 Fixed
This commit is contained in:
Michael Nedzelsky
2014-12-11 21:02:49 +03:00
parent 0b54221223
commit 12ff5de013
5 changed files with 28 additions and 2 deletions
@@ -143,6 +143,13 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
OutputFileCollection outputFiles = translate(mainCallParameters, config, sourcesFiles, outputFile, outputPrefixFile, outputPostfixFile);
if (outputFile.isDirectory()) {
messageCollector.report(CompilerMessageSeverity.ERROR,
"Cannot open output file '" + outputFile.getPath() + "': is a directory",
CompilerMessageLocation.NO_LOCATION);
return ExitCode.COMPILATION_ERROR;
}
File outputDir = outputFile.getParentFile();
if (outputDir == null) {
outputDir = outputFile.getAbsoluteFile().getParentFile();