diff --git a/package.json b/package.json index 53428ea..55f3561 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ "changelog": "auto-changelog", "coverage:badge": "istanbul-badges-readme", "ci": "env && git fetch --tags && npm run lint && npm run build && npm run update:subs && npm run test && npm run changelog", - "publish:subs": "sh scripts/publish_all_subs.sh", + "copy:to-subs": "sh scripts/copy_to_all_subs.sh", + "publish:subs": "npm run copy:to-subs && sh scripts/publish_all_subs.sh", "publish:docs": "sh scripts/publish_docs.sh", "publish:all": "npm run ci && npm publish && npm run publish:subs && npm run publish:docs" }, diff --git a/scripts/copy_to_all_subs.sh b/scripts/copy_to_all_subs.sh new file mode 100644 index 0000000..f8befe0 --- /dev/null +++ b/scripts/copy_to_all_subs.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Enable extended globbing +shopt -s extglob + +# target directory +individuals_dir_default=$(jq -r .individualsDir ./scripts/config.json) + +# Source directory +source_dir_default=$(jq -r .sourceDir ./scripts/config.json) + +# List of directories +directories=( + "avl-tree-typed" + +) + +# Loop through each directory +for dir in "${directories[@]}"; do + # Delete all files except index.ts + find "$individuals_dir_default"/"$dir"/src -type f ! -name 'index.ts' -delete + + # Copy the files to the target directory, excluding index.ts + cp -R "$source_dir_default"/src/!(index.ts) "$individuals_dir_default"/"$dir"/src +done + +echo "All packages copied."