File tree 2 files changed +11
-12
lines changed
2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -249,19 +249,23 @@ struct Dependency {
249
249
string (`versionSpec`), while more complex specifications will be
250
250
represented as a JSON object with optional "version", "path", "optional"
251
251
and "default" fields.
252
+
253
+ Params:
254
+ selections = We are serializing `dub.selections.json`, don't write out
255
+ `optional` and `default`.
252
256
*/
253
- Json toJson ()
257
+ Json toJson (bool selections = false )
254
258
const @trusted { // NOTE Path and Json is @system in vibe.d 0.7.x and in the compatibility layer
255
259
Json json;
256
- if ( path.empty && repository.empty && ! optional ) {
260
+ if ( path.empty && repository.empty && ( ! optional || selections)) {
257
261
json = Json(this .versionSpec);
258
262
} else {
259
263
json = Json.emptyObject;
260
264
json[" version" ] = this .versionSpec;
261
265
if (! path.empty) json[" path" ] = path.toString();
262
266
if (! repository.empty) json[" repository" ] = repository.toString;
263
- if (optional) json[" optional" ] = true ;
264
- if (default_) json[" default" ] = true ;
267
+ if (! selections && optional) json[" optional" ] = true ;
268
+ if (! selections && default_) json[" default" ] = true ;
265
269
}
266
270
return json;
267
271
}
Original file line number Diff line number Diff line change @@ -1843,15 +1843,10 @@ final class SelectedVersions {
1843
1843
m_bare = false ;
1844
1844
}
1845
1845
1846
+ deprecated (" Use `dub.dependency : Dependency.toJson(true)`" )
1846
1847
static Json dependencyToJson (Dependency d)
1847
1848
{
1848
- if (! d.repository.empty) {
1849
- return serializeToJson ([
1850
- " version" : d.version_.toString(),
1851
- " repository" : d.repository.toString,
1852
- ]);
1853
- } else if (d.path.empty) return Json(d.version_.toString());
1854
- else return serializeToJson([" path" : d.path.toString()]);
1849
+ return d.toJson(true );
1855
1850
}
1856
1851
1857
1852
static Dependency dependencyFromJson (Json j)
@@ -1873,7 +1868,7 @@ final class SelectedVersions {
1873
1868
serialized[" fileVersion" ] = m_selections.fileVersion;
1874
1869
serialized[" versions" ] = Json.emptyObject;
1875
1870
foreach (p, dep; m_selections.versions)
1876
- serialized[" versions" ][p] = dependencyToJson( dep);
1871
+ serialized[" versions" ][p] = dep.toJson( true );
1877
1872
return serialized;
1878
1873
}
1879
1874
You can’t perform that action at this time.
0 commit comments