-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,277 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/com/featurevisor/testRunner/CommandExecuter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.featurevisor.testRunner | ||
|
||
import java.io.File | ||
import java.io.IOException | ||
import java.util.concurrent.TimeUnit | ||
|
||
internal fun getJsonForFeatureUsingCommand(featureName: String, environment: String, projectRootPath: String) = | ||
try { | ||
createCommand(featureName, environment).runCommand(getFileForSpecificPath(projectRootPath)) | ||
} catch (e: Exception) { | ||
printMessageInRedColor("Exception in Commandline execution --> ${e.message}") | ||
null | ||
} | ||
|
||
private fun createCommand(featureName: String, environment: String) = | ||
"npx featurevisor build --feature=$featureName --environment=$environment --print --pretty" | ||
|
||
private fun String.runCommand(workingDir: File): String? = | ||
try { | ||
val parts = this.split("\\s".toRegex()) | ||
val process = ProcessBuilder(*parts.toTypedArray()) | ||
.directory(workingDir) | ||
.redirectOutput(ProcessBuilder.Redirect.PIPE) | ||
.redirectError(ProcessBuilder.Redirect.PIPE) | ||
.start() | ||
process.waitFor(60, TimeUnit.MINUTES) | ||
process.inputStream.bufferedReader().readText() | ||
} catch (e: IOException) { | ||
printMessageInRedColor("Exception while executing command -> ${e.message}") | ||
null | ||
} |
Oops, something went wrong.