add shellcheck

pull/106/head
Muhammad Atif Ali 2 years ago
parent 0064ce3fea
commit 48e13432fc

@ -35,4 +35,4 @@ jobs:
- name: Format - name: Format
run: bun fmt:ci run: bun fmt:ci
- name: Lint - name: Lint
run: bun install && bun lint run: bun lint

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env sh
# Convert templated variables to shell variables
LOG_PATH=${LOG_PATH}
BOLD='\033[0;1m' BOLD='\033[0;1m'
printf "$${BOLD}Installing MODULE_NAME ...\n\n" printf "$${BOLD}Installing MODULE_NAME ...\n\n"
@ -13,6 +16,6 @@ printf "👷 Starting MODULE_NAME in background...\n\n"
# 1. Use & to run it in background # 1. Use & to run it in background
# 2. redirct stdout and stderr to log files # 2. redirct stdout and stderr to log files
./app >${LOG_PATH} 2>&1 & ./app > "$${LOG_PATH}" 2>&1 &
printf "check logs at ${LOG_PATH} \n\n" printf "check logs at %s\n\n" "$${LOG_PATH}"

Binary file not shown.

@ -7,15 +7,15 @@ MODULE_NAME=$1
# Check if module name is provided # Check if module name is provided
if [ -z "$MODULE_NAME" ]; then if [ -z "$MODULE_NAME" ]; then
echo "Usage: ./new.sh <module_name>" echo "Usage: ./new.sh <module_name>"
exit 1 exit 1
fi fi
# Create module directory and exit if it alredy exists # Create module directory and exit if it alredy exists
if [ -d "$MODULE_NAME" ]; then if [ -d "$MODULE_NAME" ]; then
echo "Module with name $MODULE_NAME already exists" echo "Module with name $MODULE_NAME already exists"
echo "Please choose a different name" echo "Please choose a different name"
exit 1 exit 1
fi fi
mkdir -p "${MODULE_NAME}" mkdir -p "${MODULE_NAME}"
@ -23,17 +23,17 @@ mkdir -p "${MODULE_NAME}"
cp -r .sample/* "${MODULE_NAME}" cp -r .sample/* "${MODULE_NAME}"
# Change to module directory # Change to module directory
cd "${MODULE_NAME}" cd "${MODULE_NAME}" || echo "Failed to change directory to ${MODULE_NAME}" && exit 1
# Detect OS # Detect OS
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS # macOS
sed -i '' "s/MODULE_NAME/${MODULE_NAME}/g" main.tf sed -i '' "s/MODULE_NAME/${MODULE_NAME}/g" main.tf
sed -i '' "s/MODULE_NAME/${MODULE_NAME}/g" README.md sed -i '' "s/MODULE_NAME/${MODULE_NAME}/g" README.md
else else
# Linux # Linux
sed -i "s/MODULE_NAME/${MODULE_NAME}/g" main.tf sed -i "s/MODULE_NAME/${MODULE_NAME}/g" main.tf
sed -i "s/MODULE_NAME/${MODULE_NAME}/g" README.md sed -i "s/MODULE_NAME/${MODULE_NAME}/g" README.md
fi fi
# Make run.sh executable # Make run.sh executable

@ -2,15 +2,16 @@
"name": "modules", "name": "modules",
"scripts": { "scripts": {
"test": "bun test", "test": "bun test",
"fmt": "bun x prettier --plugin prettier-plugin-sh -w **/*.sh **/*.ts **/*.md *.md && terraform fmt **/*.tf", "fmt": "bun x prettier --plugin prettier-plugin-sh -w **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt **/*.tf .sample/main.tf",
"fmt:ci": "bun x prettier --plugin prettier-plugin-sh --check **/*.sh **/*.ts **/*.md *.md && terraform fmt -check **/*.tf", "fmt:ci": "bun x prettier --plugin prettier-plugin-sh --check **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt -check **/*.tf .sample/main.tf",
"lint": "bun run lint.ts" "lint": "bun run lint.ts && bun x shellcheck **/*.sh .sample/run.sh new.sh"
}, },
"devDependencies": { "devDependencies": {
"bun-types": "^1.0.3", "bun-types": "^1.0.3",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"marked": "^9.0.3", "marked": "^9.0.3",
"prettier-plugin-sh": "^0.13.1" "prettier-plugin-sh": "^0.13.1",
"shellcheck": "^2.2.0"
}, },
"peerDependencies": { "peerDependencies": {
"typescript": "^5.0.0" "typescript": "^5.0.0"

Loading…
Cancel
Save