-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopyCradleMermaid.sh
More file actions
89 lines (69 loc) · 2.57 KB
/
Copy pathCopyCradleMermaid.sh
File metadata and controls
89 lines (69 loc) · 2.57 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
set -eu
search_root="${OBJROOT}/BuildToolPluginIntermediates"
destination_directory="${SRCROOT}/.cradle"
destination="${destination_directory}/DependencyGraph.mmd"
matches="${TARGET_TEMP_DIR}/cradle-diagram-paths.txt"
temporary=""
cleanup() {
/bin/rm -f "${matches}"
if [ -n "${temporary}" ]; then
/bin/rm -f "${temporary}"
fi
}
trap cleanup EXIT
: > "${matches}"
case "${TARGET_NAME}" in
*/*)
echo "warning: Xcode target 이름에 경로 구분자가 있어 기존 파일을 유지합니다."
exit 0
;;
esac
target_path_pattern=$(printf '%s' "${TARGET_NAME}" | /usr/bin/sed 's/[][\\*?]/\\&/g')
if [ -d "${search_root}" ]; then
if ! /usr/bin/find "${search_root}" \
-type f \
! -type l \
-path "*/${target_path_pattern}/CradlePlugin/CradleDiagrams/*/DependencyGraph.mmd" \
-print > "${matches}"; then
echo "warning: Cradle DependencyGraph.mmd를 찾지 못해 기존 파일을 유지합니다."
exit 0
fi
fi
count=$(/usr/bin/wc -l < "${matches}" | /usr/bin/tr -d ' ')
if [ "${count}" -ne 1 ]; then
echo "warning: Cradle DependencyGraph.mmd 후보를 하나로 결정하지 못해 기존 파일을 유지합니다."
exit 0
fi
source_path=$(/usr/bin/sed -n '1p' "${matches}")
if [ ! -f "${source_path}" ] || [ -L "${source_path}" ]; then
echo "warning: Cradle DependencyGraph.mmd가 없어 기존 파일을 유지합니다."
exit 0
fi
if [ -L "${destination_directory}" ] || { [ -e "${destination_directory}" ] && [ ! -d "${destination_directory}" ]; }; then
echo "warning: .cradle 경로를 안전하게 쓸 수 없어 기존 파일을 유지합니다."
exit 0
fi
if [ -L "${destination}" ] || { [ -e "${destination}" ] && [ ! -f "${destination}" ]; }; then
echo "warning: DependencyGraph.mmd 경로를 안전하게 쓸 수 없어 기존 파일을 유지합니다."
exit 0
fi
if ! /bin/mkdir -p "${destination_directory}"; then
echo "warning: .cradle 디렉터리를 만들지 못해 기존 파일을 유지합니다."
exit 0
fi
if [ -f "${destination}" ] && /usr/bin/cmp -s "${source_path}" "${destination}"; then
exit 0
fi
if ! temporary=$(/usr/bin/mktemp "${destination_directory}/.DependencyGraph.mmd.XXXXXX"); then
echo "warning: Cradle DependencyGraph.mmd 임시 파일을 만들지 못해 기존 파일을 유지합니다."
exit 0
fi
if ! /bin/cp "${source_path}" "${temporary}"; then
echo "warning: Cradle DependencyGraph.mmd 복사에 실패해 기존 파일을 유지합니다."
exit 0
fi
if ! /bin/mv -f "${temporary}" "${destination}"; then
echo "warning: Cradle DependencyGraph.mmd 반영에 실패해 기존 파일을 유지합니다."
exit 0
fi