Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions shell/languages/nodejs.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/usr/bin/env bash
# Helpers for node.js

# shellcheck source=../lib/logging.sh
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../lib/logging.sh"

# shellcheck source=../lib/shell.sh
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../lib/shell.sh"

yarn_install_if_needed() {
local stateFile="node_modules/devbase.lock"

if [[ ! -e "package.json" ]]; then
warn "No package.json found, skipping yarn install"
return
fi

if ! yarn -v >/dev/null 2>&1; then
npm install -g yarn
fi
Expand Down
7 changes: 7 additions & 0 deletions shell/linters/prettier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ source "$DIR/languages/nodejs.sh"
extensions=(yaml yml json md ts)

PRETTIER="node_modules/.bin/prettier"
if [[ ! -f $PRETTIER ]] && [[ ! -f package.json ]]; then
# Try to find prettier installed via mise
PRETTIER="$(mise which prettier)"
if [[ -z $PRETTIER ]]; then
fatal "prettier not found in repo"
fi
fi

prettier_log_level_flag() {
if [[ $("$PRETTIER" --version) =~ ^2 ]]; then
Expand Down