From 0fc2eb03c6b94659263349d3f3d7d13bdfb5bde0 Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Wed, 1 Dec 2021 15:45:13 +0300 Subject: [PATCH] Add user defined enviroment for copy-paste decetion script --- xcode/aux_scripts/install_env.sh | 14 +++++++++++++- xcode/build_phases/copy_paste_detection.sh | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/xcode/aux_scripts/install_env.sh b/xcode/aux_scripts/install_env.sh index 65b8353..ce6c803 100644 --- a/xcode/aux_scripts/install_env.sh +++ b/xcode/aux_scripts/install_env.sh @@ -1,3 +1,13 @@ +# Description: +# Add user defined enviroment if programm not found +# +# Parameters: +# $1 - programm +# +# Examples of usage: +# . install_env.sh pmd +# + # When you run Git from the command line, it runs in the environment as set up by your Shell. # GUI OS X apps, however, have no knowledge about your shell - and the PATH environment can be changed in many different places. # Export our profile with path by ourselves @@ -8,6 +18,8 @@ function source_home_file { } # Use specific exec due to Xcode has custom value of $PATH -if [ -z "$(which pmd)" ]; then +if [ -z "$(which $1)" ]; then source_home_file ".bash_profile" || source_home_file ".zshrc" || true + + echo "User defined enviroment has been set" fi \ No newline at end of file diff --git a/xcode/build_phases/copy_paste_detection.sh b/xcode/build_phases/copy_paste_detection.sh index 653b093..e29cda1 100755 --- a/xcode/build_phases/copy_paste_detection.sh +++ b/xcode/build_phases/copy_paste_detection.sh @@ -24,6 +24,12 @@ readonly EXIT_SUCCESS=0 readonly EXIT_FAILURE=1 +if ! which pmd >/dev/null; then + echo "pmd is not found, trying add user defined enviroment" + + . ${SCRIPT_DIR}/../aux_scripts/install_env.sh pmd +fi + if which pmd >/dev/null; then readonly REPORTS_DIR="${PROJECT_DIR}/code-quality-reports"