lib: add fileContents function

This commit is contained in:
Eric Sagnes 2016-07-29 17:15:37 +09:00
parent 0804f67024
commit 56575cc0ac

View File

@ -479,4 +479,14 @@ rec {
absolutePaths = builtins.map (path: builtins.toPath (root + "/" + path)) relativePaths;
in
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);
}