Skip to content

Instantly share code, notes, and snippets.

@bpkennedy
Last active April 13, 2020 04:46
Show Gist options
  • Save bpkennedy/18977514f0bc3925cce007b2563e7de6 to your computer and use it in GitHub Desktop.
Save bpkennedy/18977514f0bc3925cce007b2563e7de6 to your computer and use it in GitHub Desktop.
Wonderdraft git config example
#!/bin/bash
# Example of simply copying from a local directory called /Wonderdraft which contains /assets, /maps, and /themes
# and recursively copies them up to the specified local paths in your wonderdraft.config file.
# Purpose is to allow all custom assets, maps, and themes to be source controlled and available across multiple OS types.
# This script expects to live and be executed from the project root.
# wonderdraft.config file should also live at the project root.
# You may need to grant permission to execute this script by your OS (`chmod 755 ./installWonderdraftResources.sh` in Linux/Mac, etc..)
# Supports Linux, MacOS, and Windows
#################################
# Source in our paths from the config file
. ./wonderdraft.config
# Define some colors
GREEN='\e[1;32m'
BLUE='\e[1;34m'
RED='\e[1;31m'
NC='\e[0m'
printf "\n${GREEN}Preparing to copy Wonderdraft assets, maps, themes. \nOperating System type discovered is: ${BLUE}... $OSTYPE${NC}\n"
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux OS
cp -a ./Wonderdraft/. "$wonderdraftLinuxUserDirectoryPath"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS
rsync --progress -r ./Wonderdraft/* "$wonderdraftMacUserDirectoryPath"
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
robocopy ./Wonderdraft "$wonderdraftWindowsUserDirectoryPath" /e
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
robocopy ./Wonderdraft "$wonderdraftWindowsUserDirectoryPath" /e
elif [[ "$OSTYPE" == "win32" ]]; then
# I'm not sure this can happen.
robocopy ./Wonderdraft "$wonderdraftWindowsUserDirectoryPath" /e
elif [[ "$OSTYPE" == "freebsd"* ]]; then
printf "${RED}FreeBSD OS is NOT SUPPORTED for copying Wonderdraft assets, maps, themes\n${NC}"
exit 1
else
printf "${RED}Unknown Operating System; Cannot copy Wonderdraft assets, maps, themes\n${NC}"
exit 1
fi
printf "${GREEN}Copy complete.\n${NC}"
exit 0
{
"name": "your-project",
"version": "1.0.0",
"description": "My map project with example postinstall hook that copies resources.",
"scripts": {
"postinstall": "./installWonderdraftResources.sh"
},
"license": "MIT"
}
wonderdraftMacUserDirectoryPath="$HOME/Library/Application Support/Wonderdraft/"
wonderdraftLinuxUserDirectoryPath="$HOME/.local/share/Wonderdraft/"
wonderdraftWindowsUserDirectoryPath="%HOMEDRIVE%%HOMEPATH%\AppData\Roaming\Wonderdraft\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment