-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopy_node_modules.sh
More file actions
executable file
·36 lines (25 loc) · 1.1 KB
/
copy_node_modules.sh
File metadata and controls
executable file
·36 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Get the root directory
root_dir="."
# Find all immediate subdirectories in packages and apps
package_dirs=$(find ./packages -maxdepth 1 -mindepth 1 -type d)
app_dirs=$(find ./apps -maxdepth 1 -mindepth 1 -type d)
# Combine all directories
directories=("$root_dir" $package_dirs $app_dirs)
# Loop through each directory
for dir in "${directories[@]}"; do
echo "Copying node_modules from $dir"
# Create a tar archive of the node_modules directory inside the container
docker exec open-react-hub_docs-dev_1 tar -czf "/tmp/${dir//\//_}_node_modules.tar.gz" -C "/app/$dir" node_modules
# Create the local directory if it doesn't exist
mkdir -p "$dir"
# Copy the tar file from the container to your local machine
docker cp "open-react-hub_docs-dev_1:/tmp/${dir//\//_}_node_modules.tar.gz" "$dir/node_modules.tar.gz"
# Extract the tar file locally
tar -xzf "$dir/node_modules.tar.gz" -C "$dir"
# Remove the tar file
rm "$dir/node_modules.tar.gz"
echo "Finished copying node_modules from $dir"
echo "--------------------"
done
echo "All node_modules directories have been copied."