lib: add fileContents function
This commit is contained in:
parent
0804f67024
commit
56575cc0ac
|
@ -479,4 +479,14 @@ rec {
|
||||||
absolutePaths = builtins.map (path: builtins.toPath (root + "/" + path)) relativePaths;
|
absolutePaths = builtins.map (path: builtins.toPath (root + "/" + path)) relativePaths;
|
||||||
in
|
in
|
||||||
absolutePaths;
|
absolutePaths;
|
||||||
|
|
||||||
|
/* Read the contents of a file removing the trailing \n
|
||||||
|
|
||||||
|
Example:
|
||||||
|
$ echo "1.0" > ./version
|
||||||
|
|
||||||
|
fileContents ./version
|
||||||
|
=> "1.0"
|
||||||
|
*/
|
||||||
|
fileContents = file: removeSuffix "\n" (builtins.readFile file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue