rework watch command
This commit is contained in:
parent
4f6c21ec77
commit
3faf0e6354
6 changed files with 32 additions and 61 deletions
|
|
@ -3,4 +3,5 @@
|
|||
it = import ./it.nix;
|
||||
test = import ./test.nix;
|
||||
watch = import ./watch.nix pkgs;
|
||||
filters = import ./filters.nix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ pkgs: files: let
|
|||
in (pkgs.writeShellScriptBin "test" ''
|
||||
t=$1
|
||||
case "$t" in
|
||||
"file") echo '${resFile}' ;;
|
||||
"raw") cat '${resFile}' ;;
|
||||
"json") jq '.' '${resFile}' ;;
|
||||
"nix") ${extractNix} | ${pkgs.alejandra}/bin/alejandra -q ;;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
pkgs: {
|
||||
cmd,
|
||||
setup ? null,
|
||||
stop ? null,
|
||||
process ? "echo \"$out\"",
|
||||
view ? null,
|
||||
}:
|
||||
pkgs.writeShellScriptBin "watch" ''
|
||||
path=''${1:-.}
|
||||
${toString setup}
|
||||
while true
|
||||
do
|
||||
${cmd} ${
|
||||
if view == null
|
||||
then ""
|
||||
else "| ${view} "
|
||||
}&
|
||||
${pkgs.inotify-tools}/bin/inotifywait -e modify -r .
|
||||
out=$(${cmd})
|
||||
${process}
|
||||
${if view == null then "" else ''
|
||||
echo "$out" | ${view}
|
||||
''}
|
||||
${pkgs.inotify-tools}/bin/inotifywait -q -e modify -r $path
|
||||
${toString stop}
|
||||
done
|
||||
''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue