working file-watch on windows
This commit is contained in:
1
projects/file-watch/.gitignore
vendored
Normal file
1
projects/file-watch/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
test-output.txt
|
@@ -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 {}
|
||||
|
@@ -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)))))
|
1
projects/file-watch/test-file.txt
Normal file
1
projects/file-watch/test-file.txt
Normal file
@@ -0,0 +1 @@
|
||||
hey
|
@@ -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
|
Reference in New Issue
Block a user