Improve cargo-flow

a0bf46ff2e88615daed2ace5924b0d926758108d
Alexis Sellier committed ago 1 parent a9ed0551
bin/cargo-flow +1 -1
7 7
# Remove the "flow" argument.
8 8
shift
9 9
10 10
cmd="flow-check $@"
11 11
12 -
# Exec cargo-watch with `flow-once`
12 +
# Exec cargo-watch with `flow-check`
13 13
exec cargo watch -qc -i 'target/*' -i errors.err -x "$cmd"
bin/cargo-flow-check +4 -12
2 2
3 3
# Shift process name parameter out.
4 4
shift
5 5
6 6
tmpfile=$(mktemp /tmp/cargo-flow.XXXXXX)
7 -
result="$(cargo check --color always --all $@ 2>&1 1>/dev/null)"
7 +
result="$(cargo $@ --color always --all 2>&1)"
8 8
9 9
if [ "$?" -ne 0 ]; then
10 10
	# Display the results, but also output them to `errors.err`, which vim
11 -
	# can read.
12 -
	echo "$result" | tee errors.err
13 -
14 -
	# We have to do this dance with the tempfile, because `sed`
15 -
	# isn't able to do the edits in memory (for some reason),
16 -
	# and creates a temporary file in $PWD which triggers `cargo watch`.
17 -
	#
18 -
	#          (╯°□°)╯︵ ┻━┻
19 -
	#
20 -
	sed -r 's/\x1b\[[0-9;]*m?//g' errors.err > $tmpfile
21 -
	mv -f $tmpfile errors.err
11 +
	# can read, after stripping any ANSI escape sequences.
12 +
	echo -n "$result" | tee $tmpfile
13 +
	sed -r 's/\x1b\[[0-9;]*m?//g' $tmpfile > errors.err
22 14
else
23 15
	echo "$result"
24 16
	echo -n > errors.err
25 17
fi