Test: Move writePackageFile to UFCS, better document
This is another step in separating FSEntry from TestDub.
1 parent 203a3ca commit 29c829cb3f7a0871138584d94b1f1407fc667fc7
@Mathias Lang Mathias Lang authored on 21 Feb 2024
The Dlang Bot committed on 22 Feb 2024
Showing 1 changed file
View
35
source/dub/test/base.d
break;
}
}
 
/// Writes a package file for package `name` of version `vers` at `loc`.
public void writePackageFile (in string name, in string vers, in string recipe,
in PackageFormat fmt = PackageFormat.json,
in PlacementLocation location = PlacementLocation.user)
{
const path = FSEntry.getPackagePath(name, vers, location);
this.mkdir(path).writeFile(
NativePath(fmt == PackageFormat.json ? "dub.json" : "dub.sdl"),
recipe);
}
 
/// Returns: The final destination a specific package needs to be stored in
public static NativePath getPackagePath(in string name_, string vers,
PlacementLocation location = PlacementLocation.user)
{
}
}
}
 
/**
* Convenience function to write a package file
*
* Allows to write a package file (and only a package file) for a certain
* package name and version.
*
* Params:
* root = The root FSEntry
* name = The package name (typed as string for convenience)
* vers = The package version
* recipe = The text of the package recipe
* fmt = The format used for `recipe` (default to JSON)
* location = Where to place the package (default to user location)
*/
public void writePackageFile (FSEntry root, in string name, in string vers,
in string recipe, in PackageFormat fmt = PackageFormat.json,
in PlacementLocation location = PlacementLocation.user)
{
const path = FSEntry.getPackagePath(name, vers, location);
root.mkdir(path).writeFile(
NativePath(fmt == PackageFormat.json ? "dub.json" : "dub.sdl"),
recipe);
}