#!/bin/bash set -euo pipefail # usage: import-icons.sh ROOT ICONLIST FLAVOR SVGOUT # # positional arguments: # # ROOT path to the checkout of https://github.com/google/material-design-icons # ICONLIST path to the icons.list file in the snikket-web-portal repository # FLAVOR one of '', 'round', 'sharp', 'outlined', 'twoshade' # SVGOUT path to the newly created SVG file root="$1/src" iconlist_file="${2-tools/icons.list}" flavor="${3-round}" output_file="${4-snikket_web/static/img/icons.svg}" printf '' IFS=$'\n' while read -r icondef; do path="$(cut -d':' -f1 <<<"$icondef")" name="$(cut -d':' -f2 <<<"$icondef")" src_path="$path/materialicons$flavor" if [ ! -d "$root/$src_path" ]; then printf 'warning: %q not found in flavor %q, falling back to default\n' "$path" "$flavor" >&2 src_path="$path/materialicons" fi src_svg="$src_path/24px.svg" if [ ! -f "$root/$src_svg" ]; then printf 'error: failed to find source file for %q: %s: does not exist\n' "$path" "$src_svg" >&2 fi printf '\n' "$src_svg" >> "$output_file" printf '\n' "$name" >> "$output_file" xpath -q -e '/svg/*' "$root/$src_svg" >> "$output_file" printf '\n' >> "$output_file" printf '

\n' "$name" done < "$iconlist_file" printf '\n' >> "$output_file"