Skip to content

Commit 855c98f

Browse files
authored
Fix --output in some cases (#53) (#54)
Currently, when --output is used multiple times on the same directory, the underlying command which copies the output can fail with a misleading error message. Even if your regular expression matches a file in the target directory, you're presented with: "no files found within ./target matching the provided output regexp" If the "mv" command's stderr is printed, it shows: "mv: inter-device move failed: '/tmp/earthly/lib/rust/release' to 'target/release'; unable to remove target: Directory not empty" Since "mv" doesn't handle existing directories the way we may want here, let's use "cp -ruT" to overlay the files into the target directory (regardless of what's already present there) and then remove the temporary directory.
1 parent 15cd2ac commit 855c98f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

rust/Earthfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ COPY_OUTPUT:
109109
cd ..; \
110110
fi;
111111
RUN mkdir -p target; \
112-
mv $TMP_FOLDER/* target 2>/dev/null || echo "no files found within ./target matching the provided output regexp";
112+
if [ "$(find "$TMP_FOLDER" -type f -printf . | wc -c)" -eq 0 ]; then \
113+
echo "no files found within ./target matching the provided output regexp"; \
114+
else \
115+
cp -ruT "$TMP_FOLDER" target; \
116+
rm -rf "$TMP_FOLDER"; \
117+
fi;
113118

114119
# CROSS runs the [cross](https://github.com/cross-rs/cross) command "cross $args --target $target".
115120
# Notice that in order to run this function, +INIT must be called first.

0 commit comments

Comments
 (0)