1{ lib, buildNpmPackage, fetchFromGitHub, runCommand, hred, jq }:
2
3buildNpmPackage rec {
4 pname = "hred";
5 version = "1.5.0";
6
7 src = fetchFromGitHub {
8 owner = "danburzo";
9 repo = "hred";
10 rev = "v${version}";
11 hash = "sha256-rnobJG9Z1lXEeFm+c0f9OsbiTzxeP3+zut5LYpGzWfc=";
12 };
13
14 npmDepsHash = "sha256-POxlGWK0TJMwNWDpiK5+OXLGtAx4lFJO3imoe/h+7Sc=";
15
16 dontNpmBuild = true;
17
18 passthru.tests = {
19 simple = runCommand "${pname}-test" {} ''
20 set -e -o pipefail
21 echo '<i id="foo">bar</i>' | ${hred}/bin/hred 'i#foo { @id => id, @.textContent => text }' -c | ${jq}/bin/jq -c > $out
22 [ "$(cat $out)" = '{"id":"foo","text":"bar"}' ]
23 '';
24 };
25
26 meta = {
27 description = "Command-line tool to extract data from HTML";
28 mainProgram = "hred";
29 license = lib.licenses.mit;
30 homepage = "https://github.com/danburzo/hred";
31 maintainers = with lib.maintainers; [ tejing ];
32 };
33}