2016-09-16 17:53:53 -04:00
|
|
|
#!/bin/bash -eu
|
|
|
|
|
2016-10-03 14:20:13 -04:00
|
|
|
# Author: w0rp <devw0rp@gmail.com>
|
|
|
|
# Description: This script wraps DMD so we can get something which is capable of reading
|
|
|
|
# D code from stdin.
|
2016-09-16 17:53:53 -04:00
|
|
|
|
|
|
|
temp_file=`mktemp`
|
|
|
|
mv "$temp_file" "$temp_file".d
|
|
|
|
temp_file="$temp_file".d
|
|
|
|
|
|
|
|
trap "rm $temp_file" EXIT
|
|
|
|
|
2016-09-18 18:58:04 -04:00
|
|
|
while read; do
|
|
|
|
echo "$REPLY" >> "$temp_file"
|
2016-09-16 17:53:53 -04:00
|
|
|
done
|
|
|
|
|
2016-09-18 05:38:54 -04:00
|
|
|
# Read imports from DUB.
|
|
|
|
original_path="$(readlink -m .)"
|
|
|
|
path="$original_path"
|
|
|
|
import_line_options=''
|
|
|
|
|
|
|
|
# We need to look for variable configuration files in parent directories.
|
|
|
|
while [ "$path" != '/' ]; do
|
|
|
|
if [ -f "$path/dub.sdl" ] || [ -f "$path/dub.json" ] || [ -f "$path/package.json" ]; then
|
|
|
|
|
|
|
|
cd "$path"
|
|
|
|
|
2016-09-18 18:58:04 -04:00
|
|
|
while read import_line; do
|
2016-09-18 05:38:54 -04:00
|
|
|
import_line_options="$import_line_options -I$import_line"
|
|
|
|
done <<< "$(dub describe --import-paths)"
|
|
|
|
|
|
|
|
cd "$original_path"
|
|
|
|
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
path="$(dirname "$path")"
|
|
|
|
done
|
|
|
|
|
|
|
|
dmd $import_line_options "$@" "$temp_file"
|