How to copy all files in a directory? #663
-
Can I copy new versions of files in specific directory? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
you mean copy only newer files? i think i got some duckscript command for that. |
Beta Was this translation helpful? Give feedback.
-
@nanoqsh you can use glob_array with is_path_newer to find and copy files. https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#std__fs__GlobArray so first use glob array to fetch all files recursively, than for/in loop over results and check if newer than target and if so copy. https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#source-13 |
Beta Was this translation helpful? Give feedback.
-
So, I think the duckscript is pretty complex within my project. It is a language to be learned. But I found an opportunity to do what I need using the cross platform shell. This is great as it works on all platforms. But a few questions remain. I have a project with a server and a client on WASM. I have this project structure:
I want to build entire project into a
server/Makefile.toml:
web/Makefile.toml
|
Beta Was this translation helpful? Give feedback.
-
If you run different tasks with release or not (for debug) in the build, you can set an env var in the task. [env]
TARGET_DIR="target/debug"
[env.release]
TARGET_DIR="target/release" or inside the env of the task that builds [env]
TARGET_DIR="target/debug"
[tasks.build-release]
env = { "TARGET_DIR" = "target/release" }
# rest of the task stuff...
[tasks.copy]
#use TARGET_DIR env
Try something like this (untested) BINARY_EXTENSION = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "", mapping = { "windows" = ".exe" } }
BINARY_FILE = "server${BINARY_EXTENSION} |
Beta Was this translation helpful? Give feedback.
@nanoqsh you can use glob_array with is_path_newer to find and copy files.
https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#std__fs__GlobArray
https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#stdfsispathnewer
so first use glob array to fetch all files recursively, than for/in loop over results and check if newer than target and if so copy.
this is glob copy implementation that you can use as an example:
https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#source-13
(sorry for the loooong var names, its like that for internal duckscript commands that are implemented in duckscript to ensure nothing leaks)