mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
lib/generators.toPretty: Print [] and {} compactly
This commit is contained in:
parent
d0be9e9810
commit
05e4d371ef
@ -230,13 +230,16 @@ rec {
|
|||||||
else if false == v then "false"
|
else if false == v then "false"
|
||||||
else if null == v then "null"
|
else if null == v then "null"
|
||||||
else if isPath v then toString v
|
else if isPath v then toString v
|
||||||
else if isList v then "[" + introSpace
|
else if isList v then
|
||||||
|
if v == [] then "[ ]"
|
||||||
|
else "[" + introSpace
|
||||||
+ libStr.concatMapStringsSep introSpace (go (indent + " ")) v
|
+ libStr.concatMapStringsSep introSpace (go (indent + " ")) v
|
||||||
+ outroSpace + "]"
|
+ outroSpace + "]"
|
||||||
else if isAttrs v then
|
else if isAttrs v then
|
||||||
# apply pretty values if allowed
|
# apply pretty values if allowed
|
||||||
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
|
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
|
||||||
then v.__pretty v.val
|
then v.__pretty v.val
|
||||||
|
else if v == {} then "{ }"
|
||||||
else if v ? type && v.type == "derivation" then
|
else if v ? type && v.type == "derivation" then
|
||||||
"<derivation ${v.drvPath}>"
|
"<derivation ${v.drvPath}>"
|
||||||
else "{" + introSpace
|
else "{" + introSpace
|
||||||
|
@ -461,7 +461,9 @@ runTests {
|
|||||||
function = x: x;
|
function = x: x;
|
||||||
functionArgs = { arg ? 4, foo }: arg;
|
functionArgs = { arg ? 4, foo }: arg;
|
||||||
list = [ 3 4 function [ false ] ];
|
list = [ 3 4 function [ false ] ];
|
||||||
|
emptylist = [];
|
||||||
attrs = { foo = null; "foo bar" = "baz"; };
|
attrs = { foo = null; "foo bar" = "baz"; };
|
||||||
|
emptyattrs = {};
|
||||||
drv = deriv;
|
drv = deriv;
|
||||||
};
|
};
|
||||||
expected = rec {
|
expected = rec {
|
||||||
@ -476,7 +478,9 @@ runTests {
|
|||||||
function = "<function>";
|
function = "<function>";
|
||||||
functionArgs = "<function, args: {arg?, foo}>";
|
functionArgs = "<function, args: {arg?, foo}>";
|
||||||
list = "[ 3 4 ${function} [ false ] ]";
|
list = "[ 3 4 ${function} [ false ] ]";
|
||||||
|
emptylist = "[ ]";
|
||||||
attrs = "{ foo = null; \"foo bar\" = \"baz\"; }";
|
attrs = "{ foo = null; \"foo bar\" = \"baz\"; }";
|
||||||
|
emptyattrs = "{ }";
|
||||||
drv = "<derivation ${deriv.drvPath}>";
|
drv = "<derivation ${deriv.drvPath}>";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user