preprocess script for pkg export

This commit is contained in:
Ruben Fiszel
2024-11-30 10:45:35 +01:00
parent 702ee77232
commit 006cc17237
2 changed files with 54 additions and 1 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .",
"package": "svelte-package -o package",
"package": "./preprocess_pkg_toggle.sh && svelte-package -o package && ./preprocess_pkg_toggle.sh",
"generate-backend-client": "openapi-ts --input ../backend/windmill-api/openapi.yaml --output ./src/lib/gen --useOptions --enums javascript --format false",
"generate-backend-client-mac": "openapi-ts --input ../backend/windmill-api/openapi.yaml --output ./src/lib/gen --useOptions --enums javascript",
"pretest": "tsc --incremental -p tests/tsconfig.json",
+53
View File
@@ -0,0 +1,53 @@
#!/bin/bash
# Define the file to modify
FILE="src/lib/components/apps/editor/AppEditorHeader.svelte"
# Function to toggle commenting of a line
toggle_line_comment() {
local line="$1"
if grep -q "^//$line" "$FILE"; then
# Uncomment the line
sed -i "s|^//$line|$line|" "$FILE"
else
# Comment the line
sed -i "s|^$line|//$line|" "$FILE"
fi
}
# Function to toggle commenting of the first matching block
toggle_first_block_comment() {
local start_marker="$1"
local end_marker="$2"
# Escape the end marker for use in sed
local escaped_end_marker=$(echo "$end_marker" | sed 's|/|\\/|g')
# Check if the block is already commented
if sed -n "/$start_marker/,/$escaped_end_marker/p" "$FILE" | grep -q "^<!--"; then
# Uncomment the block
sed -i "/$start_marker/,/$escaped_end_marker/{
s|^<!-- ||
s| -->$||
}" "$FILE"
else
# Comment the block
sed -i "/$start_marker/,/$escaped_end_marker/{
s|^|<!-- |
s|$| -->|
}" "$FILE"
fi
}
# Define the line and block
LINE=" import UnsavedConfirmationModal "
BLOCK_START="<UnsavedConfirmationModal"
BLOCK_END="/>"
# Toggle the line comment
toggle_line_comment "$LINE"
# Toggle the first block comment
toggle_first_block_comment "$BLOCK_START" "$BLOCK_END"
echo "Toggled line and first block comments in $FILE."