Resolve styleguide imports before syncing upstream CSS
This commit is contained in:
@@ -68,7 +68,32 @@ PORTAL_STYLEGUIDE_DOCS_PATH="$PORTAL_REPO_PATH/$PORTAL_STYLEGUIDE_DOCS_REL"
|
|||||||
mkdir -p "$(dirname "$PORTAL_CSS_PATH")"
|
mkdir -p "$(dirname "$PORTAL_CSS_PATH")"
|
||||||
mkdir -p "$PORTAL_STYLEGUIDE_DOCS_PATH"
|
mkdir -p "$PORTAL_STYLEGUIDE_DOCS_PATH"
|
||||||
|
|
||||||
cp "$SOURCE_CSS" "$PORTAL_CSS_PATH"
|
flatten_css() {
|
||||||
|
local source_file="$1"
|
||||||
|
local source_root="$2"
|
||||||
|
local output_file="$3"
|
||||||
|
|
||||||
|
: > "$output_file"
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [[ "$line" =~ ^[[:space:]]*@import[[:space:]]+\"([^\"]+)\"[[:space:]]*\;[[:space:]]*$ ]]; then
|
||||||
|
local import_path="${BASH_REMATCH[1]}"
|
||||||
|
local import_abs="$source_root/$import_path"
|
||||||
|
if [[ ! -f "$import_abs" ]]; then
|
||||||
|
echo "Imported CSS not found: $import_abs" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cat "$import_abs" >> "$output_file"
|
||||||
|
printf "\n" >> "$output_file"
|
||||||
|
else
|
||||||
|
printf "%s\n" "$line" >> "$output_file"
|
||||||
|
fi
|
||||||
|
done < "$source_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
TMP_UPSTREAM_CSS="$(mktemp)"
|
||||||
|
trap 'rm -f "$TMP_UPSTREAM_CSS"' EXIT
|
||||||
|
flatten_css "$SOURCE_CSS" "$STYLEGUIDE_REPO_ROOT" "$TMP_UPSTREAM_CSS"
|
||||||
|
cp "$TMP_UPSTREAM_CSS" "$PORTAL_CSS_PATH"
|
||||||
|
|
||||||
rsync -a --delete \
|
rsync -a --delete \
|
||||||
--exclude ".git/" \
|
--exclude ".git/" \
|
||||||
|
|||||||
Reference in New Issue
Block a user