Reworked hasEnv to isNotSystemProperty.

This commit is contained in:
Erik C. Thauvin 2019-04-10 22:28:18 -07:00
parent e17feafd90
commit d3ebf2689e
3 changed files with 5 additions and 4 deletions

View file

@ -76,7 +76,8 @@ class SemverPlugin : Plugin<Project> {
val requiredProps = setOf(config.majorKey, config.minorKey, config.patchKey,
config.preReleaseKey, config.buildMetaKey)
hasReqProps = stringPropertyNames().containsAll(requiredProps) && !Utils.hasEnv(requiredProps)
hasReqProps = stringPropertyNames().containsAll(requiredProps) &&
Utils.isNotSystemProperty(requiredProps)
version.major = Utils.loadProperty(this, config.majorKey, Version.DEFAULT_MAJOR)
version.minor = Utils.loadProperty(this, config.minorKey, Version.DEFAULT_MINOR)

View file

@ -14,9 +14,9 @@ import java.util.Properties
* @since 1.0
*/
object Utils {
fun hasEnv(keys: Set<String>): Boolean {
fun isNotSystemProperty(keys: Set<String>): Boolean {
keys.forEach {
if (System.getProperties().containsKey(it)) return true
if (!System.getProperties().containsKey(it)) return true
}
return false
}

View file

@ -87,7 +87,7 @@ object UtilsSpec : Spek({
Pair(config.preReleaseKey, "beta"),
Pair(config.buildMetaKey, "007"))
it("should have none of our properties") {
assertFalse(Utils.hasEnv(setOf(config.majorKey, config.minorKey, config.patchKey, config.preReleaseKey,
assertFalse(Utils.isNotSystemProperty(setOf(config.majorKey, config.minorKey, config.patchKey, config.preReleaseKey,
config.buildMetaKey)))
}
it("version should match system properties") {