mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 04:43:09 +03:00
lib.strings.normalizePath: Deprecate for path values
There's no need to call this function on path data types, and it's confusing with the new lib.path library functions
This commit is contained in:
parent
99bc90e301
commit
5e8b9de728
@ -207,7 +207,20 @@ rec {
|
|||||||
normalizePath "/a//b///c/"
|
normalizePath "/a//b///c/"
|
||||||
=> "/a/b/c/"
|
=> "/a/b/c/"
|
||||||
*/
|
*/
|
||||||
normalizePath = s: (builtins.foldl' (x: y: if y == "/" && hasSuffix "/" x then x else x+y) "" (stringToCharacters s));
|
normalizePath = s:
|
||||||
|
warnIf
|
||||||
|
(isPath s)
|
||||||
|
''
|
||||||
|
lib.strings.normalizePath: The argument (${toString s}) is a path value, but only strings are supported.
|
||||||
|
Path values are always normalised in Nix, so there's no need to call this function on them.
|
||||||
|
This function also copies the path to the Nix store and returns the store path, the same as "''${path}" will, which may not be what you want.
|
||||||
|
This behavior is deprecated and will throw an error in the future.''
|
||||||
|
(
|
||||||
|
builtins.foldl'
|
||||||
|
(x: y: if y == "/" && hasSuffix "/" x then x else x+y)
|
||||||
|
""
|
||||||
|
(stringToCharacters s)
|
||||||
|
);
|
||||||
|
|
||||||
/* Depending on the boolean `cond', return either the given string
|
/* Depending on the boolean `cond', return either the given string
|
||||||
or the empty string. Useful to concatenate against a bigger string.
|
or the empty string. Useful to concatenate against a bigger string.
|
||||||
|
Loading…
Reference in New Issue
Block a user