From 5aa7b9948fe46c8d3a035db0944078c931876db2 Mon Sep 17 00:00:00 2001 From: tarassh Date: Wed, 21 Aug 2024 11:15:01 -0700 Subject: [PATCH] CI: embed script into make --- Makefile.toml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index 2ba8629..257c76d 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -41,7 +41,24 @@ command = "cargo" args = ["clippy", "--", "--deny", "warnings"] [tasks.header-add] -script = { file = "./scripts/add_header_if_missing.sh" } +script = [ + "if [ \"$#\" -lt 2 ]; then", + " echo 'Usage: $0 '", + " exit 1", + "fi", + "HEADER_FILE=\"$1\"", + "FILE_PATTERN=\"$2\"", + "LICENSE_HEADER=$(cat \"$HEADER_FILE\")", + "shopt -s globstar", + "for file in $FILE_PATTERN; do", + " if [[ -f \"$file\" && \"$file\" == *.rs ]]; then", + " if ! grep -q 'Copyright 2024, Horizen Labs, Inc.' \"$file\"; then", + " echo 'Adding license header to $file'", + " echo -e \"$LICENSE_HEADER\\n$(cat $file)\" > \"$file\"", + " fi", + " fi", + "done" +] args = ["HEADER-APACHE2", "./!(target)/**/*.rs"] [tasks.header-check]