Commit d370f2f8 authored by Winter M's avatar Winter M
Browse files

importNpmLock: handle commit in resolved git url

npm's locking process resolves Git dependencies to a given commit, separated
by a `#`. Before this change, any encounter of these URLs would cause `fetchGit`
to fail, as they're not valid repo URLs.
parent 94952876
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -52,9 +52,17 @@ let
                // fetcherOpts
              ))
            else if lib.hasPrefix "git" module.resolved then
              let
                url = elemAt mUrl 1;
                urlParts = lib.splitString "#" url;
                commit = if builtins.length urlParts == 2 then elemAt urlParts 1 else null;
              in
              (fetchGit (
                {
                  url = module.resolved;
                  url = "${scheme}://${elemAt urlParts 0}";
                }
                // lib.optionalAttrs (commit != null) {
                  rev = commit;
                }
                // fetcherOpts
              ))