-
Notifications
You must be signed in to change notification settings - Fork 21
/
copy_local.sh
42 lines (34 loc) · 1.04 KB
/
copy_local.sh
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
37
38
39
40
41
42
#!/bin/bash
copy_files() {
destination=$1
echo "Start copying to $1"
if [ -z "$2" ] || [ "$2" = "false" ]; then
files_to_exclude="`cat ./exclude_files.txt`"
dirs_to_exclude="`cat ./exclude_dirs.txt`"
robocopy . "$destination" //XD $dirs_to_exclude //XF $files_to_exclude //E
else
rsync -avz --exclude-from=exclude.txt $(pwd)/ "$destination"
fi
#shopt -s extglob
#cp -rf $(ls !(.git|.vscode|_site|.asset-cache|.contentignore|.gitignore|docs-watcher/node_modules)) $destination
echo "Copying finished."
}
update_gitignore() {
echo "Adding build related files to .gitignore..."
merged_file_name="./.merged_tmp"
dest_gitignore="$1/.gitignore"
cat $dest_gitignore ./.contentignore > $merged_file_name
sort -u $merged_file_name > $dest_gitignore
rm $merged_file_name
echo "Finished."
}
if [ -z "$1" ]
then
echo $1
echo "Required parameter is missing!"
echo "Destination folder path is not passed."
echo "Example usage: 'sh copy_local.sh \"d:\work\docs\"'"
exit 1
fi
copy_files $1 $2
update_gitignore $1