@@ -102,7 +102,7 @@ class GUIUtility(logger: ManagedLogger) {
102
102
103
103
// contains tuples with the actual file as the first value and the name with directory in the jar as the second value
104
104
val jarEntries = files.map(file => file -> s " /chatoverflow-gui/ ${dir.toURI.relativize(file.toURI).toString}" ) ++
105
- getVersionFiles(guiProjectPath).map(file => file -> s " / ${file.getName}" )
105
+ getVersionFiles(guiProjectPath).map(file => file -> s " / ${file.getName}" )
106
106
107
107
sbt.IO .jar(jarEntries, getGUIJarFile(guiProjectPath, crossTargetDir), new Manifest ())
108
108
}
@@ -132,24 +132,32 @@ class GUIUtility(logger: ManagedLogger) {
132
132
}.getOrElse(None )
133
133
134
134
private def getGUIVersion (packageJson : JsonNode ): Option [String ] = {
135
- val version = packageJson.get(" version" ).asText()
135
+ if (packageJson.has(" version" )) {
136
+ val version = packageJson.get(" version" ).asText()
136
137
137
- if (version.isEmpty) {
138
- logger warn " The GUI version couldn't be loaded from the package.json."
139
- None
138
+ if (version.isEmpty) {
139
+ logger warn " The GUI version couldn't be loaded from the package.json."
140
+ None
141
+ } else {
142
+ Option (version)
143
+ }
140
144
} else {
141
- Option (version)
145
+ None
142
146
}
143
147
}
144
148
145
149
private def getRestVersion (packageJson : JsonNode ): Option [String ] = {
146
- val version = packageJson.get(" dependencies" ).get(" @codeoverflow-org/chatoverflow" ).asText()
150
+ if (packageJson.has(" dependencies" ) && packageJson.get(" dependencies" ).hasNonNull(" @codeoverflow-org/chatoverflow" )) {
151
+ val version = packageJson.get(" dependencies" ).get(" @codeoverflow-org/chatoverflow" ).asText()
147
152
148
- if (version.isEmpty) {
149
- logger warn " The used REST api version couldn't be loaded from the package.json."
150
- None
153
+ if (version.isEmpty) {
154
+ logger warn " The used REST api version couldn't be loaded from the package.json."
155
+ None
156
+ } else {
157
+ Option (version)
158
+ }
151
159
} else {
152
- Option (version)
160
+ None
153
161
}
154
162
}
155
163
@@ -159,12 +167,12 @@ class GUIUtility(logger: ManagedLogger) {
159
167
val files = ListBuffer [File ]()
160
168
val tempDir = sbt.IO .createTemporaryDirectory
161
169
162
- getGUIVersion(json.get).foreach {ver =>
170
+ getGUIVersion(json.get).foreach { ver =>
163
171
val f = new File (tempDir, " version_gui.txt" )
164
172
sbt.IO .write(f, ver)
165
173
files += f
166
174
}
167
- getRestVersion(json.get).foreach {ver =>
175
+ getRestVersion(json.get).foreach { ver =>
168
176
val f = new File (tempDir, " version_gui_rest.txt" )
169
177
sbt.IO .write(f, ver)
170
178
files += f
0 commit comments