Skip to content

Commit

Permalink
converted most scripts to standard posix
Browse files Browse the repository at this point in the history
  • Loading branch information
kael-shipman committed Feb 15, 2024
1 parent fd34047 commit 2fff138
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion scripts/.internal/docs-view.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

pnpx http-server -o -c 60 -p 5353 ./docs
26 changes: 13 additions & 13 deletions scripts/.internal/pkgjson.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

ROOT="$(dirname "$0")/../.."
Expand All @@ -9,7 +9,7 @@ JSON=
OPERATOR="|="
DRY_RUN=

function echo_usage() {
echo_usage() {
echo "Usage:"
echo " $0 -h|--help - Show this help message and exit"
echo " $0 ([options]) set [key] [value] - Set the given key to the given value in package.json. Keys may be specified in jq format."
Expand All @@ -27,14 +27,14 @@ function echo_usage() {
echo
}

function exit_with_error() {
exit_with_error() {
>&2 echo_usage
>&2 echo
>&2 echo "E: $1"
exit 1
}

function process_set_args() {
process_set_args() {
while [ $# -gt 0 ]; do
case "$1" in
-j|--json)
Expand Down Expand Up @@ -65,31 +65,31 @@ function process_set_args() {
if [ -z "$SET_VAL" ]; then exit_with_error "No value specified"; fi
}

function process_del_args() {
process_del_args() {
DEL_KEY="$1"
if [ -z "$DEL_KEY" ]; then exit_with_error "No key specified"; fi
if [ -n "$2" ]; then exit_with_error "Unknown argument: '$2'"; fi
}

function process_sort_args() {
process_sort_args() {
if [ -n "$1" ]; then exit_with-error "Unknown argument: '$1'"; fi
}

function apply_cmd() {
apply_cmd() {
local OUTPUT
for pkgjson in "$ROOT/libs"/*/package.json; do
if ! echo "$pkgjson" | grep -Eq "$FILTER" || echo "$pkgjson" | grep -Eq "$EXCLUDE"; then
continue
fi
if [ "$CMD" == "set" ]; then
if [ "$CMD" = "set" ]; then
if [ -n "$JSON" ]; then
OUTPUT="$(jq --argjson val "$SET_VAL" "$SET_KEY += \$val" "$pkgjson")"
else
OUTPUT="$(jq --arg val "$SET_VAL" "$SET_KEY |= \$val" "$pkgjson")"
fi
elif [ "$CMD" == "delete" ]; then
elif [ "$CMD" = "delete" ]; then
OUTPUT="$(jq "del($DEL_KEY)" "$pkgjson")"
elif [ "$CMD" == "sort" ]; then
elif [ "$CMD" = "sort" ]; then
local EXTRA
OUTPUT="$(jq --sort-keys . "$pkgjson")"
if jq -e .scripts "$pkgjson" &>/dev/null; then
Expand Down Expand Up @@ -177,11 +177,11 @@ done

if [ -z "$CMD" ]; then exit_with_error "No command specified"; fi

if [ "$CMD" == "set" ]; then
if [ "$CMD" = "set" ]; then
process_set_args "$@"
elif [ "$CMD" == "delete" ]; then
elif [ "$CMD" = "delete" ]; then
process_del_args "$@"
elif [ "$CMD" == "sort" ]; then
elif [ "$CMD" = "sort" ]; then
process_sort_args "$@"
else
exit_with_error "Unknown command: '$CMD'"
Expand Down
6 changes: 3 additions & 3 deletions scripts/.internal/publish-all.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#!/bin/sh
set -e

if ! command -v jq &> /dev/null; then
if ! command -v jq 2>1 > /dev/null; then
>&2 echo "E: jq not found. You must install jq to use this script"
exit 1
fi
Expand Down Expand Up @@ -32,7 +32,7 @@ for pkg in "$ROOT/libs"/*; do
if [ "$CONFIRM" -eq 1 ]; then
read -p "Publish $PKG_NAME@$NEW_VERSION? [Y/n] " -n 1 REPLY
echo
if [[ "$REPLY" =~ ^[Nn]$ ]]; then
if echo "$REPLY" | grep -Eq '^[Nn]$'; then
echo "Skipping $PKG_NAME@$NEW_VERSION"
continue
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-react.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

pnpm vite build
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

tsc -b
2 changes: 1 addition & 1 deletion scripts/check.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

for what in typecheck prettier lint test; do
Expand Down
2 changes: 1 addition & 1 deletion scripts/clean.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

rm -Rf ./dist || true
2 changes: 1 addition & 1 deletion scripts/dev-react.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

vite $@
2 changes: 1 addition & 1 deletion scripts/docs-gen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

NM="$(basename $PWD)"
Expand Down
2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

pnpm prettier:fix
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint-fix.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

pnpm lint --fix
2 changes: 1 addition & 1 deletion scripts/prepublishOnly.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

pnpm clean
Expand Down
2 changes: 1 addition & 1 deletion scripts/prettier-fix.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

pnpm prettier --write
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

ROOT="$(dirname "$0")/.."
Expand Down
2 changes: 1 addition & 1 deletion scripts/typecheck.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

tsc --noEmit

0 comments on commit 2fff138

Please sign in to comment.