Skip to content

Commit

Permalink
Fixed fromJSON' function path check.
Browse files Browse the repository at this point in the history
  • Loading branch information
iivvaannxx committed Sep 1, 2023
1 parent 567b3e5 commit 79258dc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/parsers.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{ lib }: let

inherit (builtins) isPath readFile fromJSON;
inherit (builtins) pathExists readFile fromJSON;
inherit (lib) hasSuffix;

in {

# Same as 'fromJSON' but allows paths as an input.
fromJSON' = source: let

# Check if it's a file, if so, read it.
isFilepath = isPath path;
isFilepath = (pathExists source) && hasSuffix ".json" source;
jsonContent = if isFilepath then (readFile source) else (source);

# Parse the json contents.
Expand Down

0 comments on commit 79258dc

Please sign in to comment.