nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

Merge pull request #205557 from ncfavier/concatLines

lib/strings: add `concatLines`

authored by

Silvan Mosberger and committed by
GitHub
50e4dbf3 a743cf65

+17 -1
+1 -1
lib/default.nix
··· 94 94 subtractLists mutuallyExclusive groupBy groupBy'; 95 95 inherit (self.strings) concatStrings concatMapStrings concatImapStrings 96 96 intersperse concatStringsSep concatMapStringsSep 97 - concatImapStringsSep makeSearchPath makeSearchPathOutput 97 + concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput 98 98 makeLibraryPath makeBinPath optionalString 99 99 hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape 100 100 escapeShellArg escapeShellArgs
+11
lib/strings.nix
··· 128 128 # List of input strings 129 129 list: concatStringsSep sep (lib.imap1 f list); 130 130 131 + /* Concatenate a list of strings, adding a newline at the end of each one. 132 + Defined as `concatMapStrings (s: s + "\n")`. 133 + 134 + Type: concatLines :: [string] -> string 135 + 136 + Example: 137 + concatLines [ "foo" "bar" ] 138 + => "foo\nbar\n" 139 + */ 140 + concatLines = concatMapStrings (s: s + "\n"); 141 + 131 142 /* Construct a Unix-style, colon-separated search path consisting of 132 143 the given `subDir` appended to each of the given paths. 133 144
+5
lib/tests/misc.nix
··· 153 153 expected = "a,b,c"; 154 154 }; 155 155 156 + testConcatLines = { 157 + expr = concatLines ["a" "b" "c"]; 158 + expected = "a\nb\nc\n"; 159 + }; 160 + 156 161 testSplitStringsSimple = { 157 162 expr = strings.splitString "." "a.b.c.d"; 158 163 expected = [ "a" "b" "c" "d" ];