pad
lib.versions.pad
Docs pulled from | This Revision | 10 minutes ago
Pad a version string with zeros to match the given number of components.
Inputs
n
-
1. Function argument
version
-
2. Function argument
Examples
pad
usage example
pad 3 "1.2"
=> "1.2.0"
pad 3 "1.3-rc1"
=> "1.3.0-rc1"
pad 3 "1.2.3.4"
=> "1.2.3"
Noogle detected
Implementation
The following is the current implementation of this function.
pad =
n: version:
let
numericVersion = lib.head (lib.splitString "-" version);
versionSuffix = lib.removePrefix numericVersion version;
in
lib.concatStringsSep "." (lib.take n (lib.splitVersion numericVersion ++ lib.genList (_: "0") n))
+ versionSuffix;