Unverified Commit fd771c56 authored by Peder Bergebakken Sundt's avatar Peder Bergebakken Sundt Committed by GitHub
Browse files

[Backport release-25.05] hred: convert to finalAttrs, add binlore (#423926)

parents 5bb4db29 02507055
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -3,18 +3,18 @@
  buildNpmPackage,
  fetchFromGitHub,
  runCommand,
  hred,
  jq,
  binlore,
}:

buildNpmPackage rec {
buildNpmPackage (finalAttrs: {
  pname = "hred";
  version = "1.5.1";

  src = fetchFromGitHub {
    owner = "danburzo";
    repo = "hred";
    rev = "v${version}";
    rev = "v${finalAttrs.version}";
    hash = "sha256-+0+WQRI8rdIMbPN0eBUdsWUMWDCxZhTRLiFo1WRd2xc=";
  };

@@ -23,13 +23,15 @@ buildNpmPackage rec {
  dontNpmBuild = true;

  passthru.tests = {
    simple = runCommand "${pname}-test" { } ''
    simple = runCommand "hred-test" { } ''
      set -e -o pipefail
      echo '<i id="foo">bar</i>' | ${hred}/bin/hred 'i#foo { @id => id, @.textContent => text }' -c | ${jq}/bin/jq -c > $out
      echo '<i id="foo">bar</i>' | ${finalAttrs.finalPackage}/bin/hred 'i#foo { @id => id, @.textContent => text }' -c | ${jq}/bin/jq -c > $out
      [ "$(cat $out)" = '{"id":"foo","text":"bar"}' ]
    '';
  };

  passthru.binlore.out = binlore.synthesize finalAttrs.finalPackage "execer cannot bin/hred";

  meta = {
    description = "Command-line tool to extract data from HTML";
    mainProgram = "hred";
@@ -37,4 +39,4 @@ buildNpmPackage rec {
    homepage = "https://github.com/danburzo/hred";
    maintainers = with lib.maintainers; [ tejing ];
  };
}
})