working file-watch on windows

This commit is contained in:
2020-11-19 16:16:36 -07:00
parent 8588bfc8b7
commit 2832cc55fc
6 changed files with 33 additions and 4 deletions

1
projects/file-watch/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
test-output.txt

View File

@@ -1,6 +1,9 @@
package;
import sys.io.File;
import sys.io.Process;
import kiss.Kiss;
import kiss.Prelude;
@:build(kiss.Kiss.build("src/Main.kiss"))
class Main {}

View File

@@ -1,2 +1,19 @@
(defun check [file delay command erase]
(let [contents
(try
(File.getContent file)
(catch [e] ""))]
(if (< 0 contents.length)
#|for (line in contents.split("\n")) {
new Process(StringTools.replace(command, "{}", '"' + line + '"'));
}|#))
(if erase (File.saveContent file ""))
(Sys.sleep delay)
(check file delay command erase))
(defun main []
(trace (nth (Sys.args) 0)))
(check
(nth (Sys.args) 0)
(Std.parseFloat (nth (Sys.args) 1))
(nth (Sys.args) 2)
(= 1 (Std.parseInt (nth (Sys.args) 3)))))

View File

@@ -0,0 +1 @@
hey

View File

@@ -1,5 +1,12 @@
#! /bin/bash
haxelib dev kiss ../../
haxe build.hxml
python bin/main.py test
echo "" > test-output.txt
expected=$'hey\nhey\nhey'
if [[ $(uname) == *"MINGW"* ]] || [ $TRAVIS_OS_NAME = "windows" ]; then
expected=$'"hey" \r\n"hey" \r\n"hey"'
fi
haxe build.hxml && \
timeout 0.35 python bin/main.py test-file.txt 0.1 "echo {} >> test-output.txt" 0 || \
if [[ "$(cat test-output.txt)" != *"$expected"* ]]; then exit 1; fi