Skip to content

Commit 1875045

Browse files
authored
fix(linters): allow prettier to be installed via mise instead of package.json (#896)
1 parent 79a05ca commit 1875045

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

shell/languages/nodejs.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
#!/usr/bin/env bash
22
# Helpers for node.js
33

4+
# shellcheck source=../lib/logging.sh
5+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../lib/logging.sh"
6+
47
# shellcheck source=../lib/shell.sh
58
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../lib/shell.sh"
69

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

13+
if [[ ! -e "package.json" ]]; then
14+
warn "No package.json found, skipping yarn install"
15+
return
16+
fi
17+
1018
if ! yarn -v >/dev/null 2>&1; then
1119
npm install -g yarn
1220
fi

shell/linters/prettier.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ source "$DIR/languages/nodejs.sh"
1010
extensions=(yaml yml json md ts)
1111

1212
PRETTIER="node_modules/.bin/prettier"
13+
if [[ ! -f $PRETTIER ]] && [[ ! -f package.json ]]; then
14+
# Try to find prettier installed via mise
15+
PRETTIER="$(mise which prettier)"
16+
if [[ -z $PRETTIER ]]; then
17+
fatal "prettier not found in repo, make sure 'npx:prettier' is defined in 'mise.toml' and you have run 'mise install'"
18+
fi
19+
fi
1320

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

0 commit comments

Comments
 (0)