Skip to content

Instantly share code, notes, and snippets.

@itspbj
Created September 6, 2019 17:13
Show Gist options
  • Save itspbj/d99e689765b1a8dca5b600951f1fc5a0 to your computer and use it in GitHub Desktop.
Save itspbj/d99e689765b1a8dca5b600951f1fc5a0 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
readonly plugin_version="1.0"
readonly expected_jar_checksum="checksum"
readonly output_file_name="plugin-name-${plugin_version}.jar"
readonly output_file="/tmp/${output_file_name}"
downloadPluginJar() {
# Download the new plugin JAR and store it in a temporary output file
}
copyJarToIntelliJDirectories(){
# Get output directories from parameter
output_directories=("$@")
for directory in "${output_directories[@]}"
do
if [[ -d "$directory" ]]; then
# Install intellij plugin
cp "$output_file" "$directory"
fi
done
}
deletePluginJar() {
rm -f "$output_file"
}
installPlugin() {
# Create array for directories that need plugin installation
output_directories=()
for directory in ~/Library/Application\ Support/*Idea*
do
has_plugin=false
# Iterate over plugin files in the IntelliJ plugin directory
for existing_plugin in "$directory"/lyft-android-intellij-plugin*
do
if [[ -e ${existing_plugin} ]]; then
filename=$(basename -- "$existing_plugin")
if [[ "$filename" == "$output_file_name" ]]; then
has_plugin=true
else
rm -rf "$existing_plugin"
fi
fi
done
# If we do not have the plugin, add the directory to the list of installation directories
if [[ "$has_plugin" = false ]]; then
output_directories+=("$directory")
fi
done
# If the array is not empty, download and install the plugin
if (( ${#output_directories[@]} )); then
downloadPluginJar
copyJarToIntelliJDirectories "${output_directories[@]}"
deletePluginJar
print_success "Plugin has been installed (will be available after IntelliJ restart)."
fi
}
installPlugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment