fix parsing CRLF formatted files

This commit is contained in:
DavHau 2021-10-07 16:25:28 +07:00
parent 1c48002dfc
commit d06519bce0
4 changed files with 5 additions and 2 deletions

View File

@ -69,6 +69,7 @@
shellHook = ''
export NIX_PATH=nixpkgs=${nixpkgs}
export d2nExternalSources=${externalSourcesFor."${system}"}
'';
});
};

View File

@ -16,7 +16,7 @@
}:
let
b = builtins;
yarnLock = "${lib.elemAt inputDirectories 0}/yarn.lock";
yarnLock = utils.readTextFile "${lib.elemAt inputDirectories 0}/yarn.lock";
packageJSON = b.fromJSON (b.readFile "${lib.elemAt inputDirectories 0}/package.json");
parser = import ./parser.nix { inherit lib; inherit (externals) nix-parsec;};
tryParse = parser.parseLock yarnLock;

View File

@ -73,5 +73,5 @@ rec {
(skipThen skipEmptyLinesAndComments
(thenSkip (sepBy group newLine) eof));
parseLock = path: nix-parsec.parsec.runParser configFile (builtins.readFile path);
parseLock = text: nix-parsec.parsec.runParser configFile text;
}

View File

@ -17,6 +17,8 @@ rec {
readDreamLock = callPackageDream ./readDreamLock.nix {};
readTextFile = file: lib.replaceStrings [ "\r\n" ] [ "\n" ] (b.readFile file);
isFile = path: (builtins.readDir (b.dirOf path))."${b.baseNameOf path}" == "regular";
isDir = path: (builtins.readDir (b.dirOf path))."${b.baseNameOf path}" == "directory";