Skip to content

Commit

Permalink
Add a huge ugly hack for golden tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
my-name-is-lad committed Jul 2, 2024
1 parent 6dbecf1 commit 5618b18
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ pkgs ? import <nixpkgs> {} }:

let
patched-yq = import ./yq.nix { inherit pkgs; };
in
pkgs.mkShell {
buildInputs = with pkgs; [ pkg-config patched-yq zlib ];
}
24 changes: 24 additions & 0 deletions nix/yq.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ pkgs ? import <nixpkgs> {} }:

# Make yq work inside whatever `stack test` launches.

let
yq-patch = pkgs.writeText "yq-tty-fix.patch" ''
diff --git a/yq/__init__.py b/yq/__init__.py
index d95ac4b..ae7d59e 100644
--- a/yq/__init__.py
+++ b/yq/__init__.py
@@ -110,7 +110,7 @@ def cli(args=None, input_format="yaml", program_name="yq"):
in_place = args.in_place
delattr(args, "in_place")
- if sys.stdin.isatty() and not args.input_streams:
+ if (sys.stdin is None or sys.stdin.isatty()) and not args.input_streams:
parser.print_help()
sys.exit(2)
elif not args.input_streams:
'';
in
pkgs.yq.overrideAttrs (final: old: {
patches = old.patches ++ [ yq-patch ];
})

0 comments on commit 5618b18

Please sign in to comment.