Skip to content

Commit

Permalink
Make sure parent directory for output is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
machaval committed Apr 5, 2021
1 parent 3fb0072 commit 1d1b311
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ subprojects {
group 'org.mule.weave.native'
version nativeVersion

// compileScala {
// targetCompatibility = "11"
// sourceCompatibility = "11"
// }
//
//
// compileJava {
// sourceCompatibility = '11'
// targetCompatibility = '11'
// }
compileScala {
targetCompatibility = "11"
sourceCompatibility = "11"
}


compileJava {
sourceCompatibility = '11'
targetCompatibility = '11'
}


publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class DataWeaveCLIRunner {
})
}

config.properties.foreach((prop) =>{
config.properties.foreach((prop) => {
scriptingBindings.addBinding(prop._1, StringValue(prop._2))
})

Expand Down Expand Up @@ -478,7 +478,19 @@ class DataWeaveCLIRunner {
}
}
} else {
val out: OutputStream = if (config.outputPath.isDefined) new FileOutputStream(config.outputPath.get) else System.out
val out: OutputStream = if (config.outputPath.isDefined) {
val outputFile = new File(config.outputPath.get)
if (!outputFile.getParentFile.exists()) {
val created = outputFile.getParentFile.mkdirs()
if(!created){
println(AnsiColor.red(s"Unable to create output file folder: `${outputFile.getParent}``"))
return -1
}
}
new FileOutputStream(outputFile)
} else {
System.out
}
val defaultOutputType = Option(System.getenv(DW_DEFAULT_OUTPUT_MIMETYPE_VAR)).getOrElse("application/json")
val result: WeaveExecutionResult = nativeRuntime.run(module.content, module.nameIdentifier, scriptingBindings, Some(out), defaultOutputType, config.profile, config.remoteDebug, config.telemetry)
//load inputs from
Expand Down

0 comments on commit 1d1b311

Please sign in to comment.