-
Notifications
You must be signed in to change notification settings - Fork 8
/
update_server
executable file
·31 lines (27 loc) · 1.14 KB
/
update_server
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
#!/usr/bin/env bash
set -eou pipefail
# Assumes [email protected]:microsoft/java-debug.git is checked out to a sibling directory.
server_dir="server"
java_debug_dir="../java-debug"
jar_path="${java_debug_dir}/com.microsoft.java.debug.plugin/target"
jar_file="com.microsoft.java.debug.*.jar"
pushd "${java_debug_dir}" &>/dev/null || exit 1
git pull
./mvnw clean package
popd &>/dev/null || exit 1
find "${jar_path}" -maxdepth 1 -type f -name "${jar_file}" -exec cp -vf '{}' "${server_dir}" \;
jars=$(find "${server_dir}" -type f -name "${jar_file}" | sort)
jar_count=$(echo "${jars}" | wc -l)
if [[ "${jar_count}" -lt 2 ]]; then
echo -e "\nThere was no server update. package.json remains the same."
exit 0
fi
old_jar=$(echo "${jars}" | head -1)
rm "${old_jar}"
new_jar=$(find "${server_dir}" -type f -name "${jar_file}" | tail -1)
escaped_new_jar=$(printf '%s\n' "${new_jar}" | sed -e 's/[\/&]/\\&/g')
sed -i "" \
-e "s/${server_dir}\/com\.microsoft\.java\.debug\.plugin-[[:digit:]]\{1,2\}\.[[:digit:]]\{1,2\}\.[[:digit:]]\{1,2\}\.jar/${escaped_new_jar}/g" \
package.json
echo -e "\npackage.json updated to [${new_jar}]"
git add -f "${server_dir}" package.json