mirror of
https://github.com/vale981/apheleia
synced 2025-03-04 09:01:42 -05:00

This adds support for formatters installed locally in project directories via yarn 2's "zero install" [pnp mode](https://yarnpkg.com/features/pnp). It's quite similar to the support for formatters installed locally in a project's `node_modules` via npm, and leverages the `npx` symbol, so existing formatter definitions should work without modification. This checks for a `.pnp.cjs` file (expected in the project root for yarn pnp projects), then looks for a yarn executable, and checks the version of yarn to make sure it supports pnp. If that works, we just push `"yarn"` onto the front of `command`. I've only tested this with a locally installed `prettier.js`. It's very much a works-for-me draft, I'm putting in a PR to make sure this is a workable approach before going any further with it. --------- Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
29 lines
517 B
Bash
Executable file
29 lines
517 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
set -o pipefail
|
|
|
|
find=(
|
|
find .
|
|
-name .git -prune -o
|
|
-name .log -prune -o
|
|
-path ./scripts/pnp-bin.js -prune -o
|
|
-path ./test/formatters -prune -o
|
|
-name "*.elc" -o
|
|
-type f -print
|
|
)
|
|
|
|
readarray -t files < <("${find[@]}" | sed 's#./##' | sort)
|
|
|
|
code="$(cat <<"EOF"
|
|
|
|
(length($0) >= 80 && $0 !~ /https?:\/\//) \
|
|
{ printf "%s:%d: %s\n", FILENAME, NR, $0 }
|
|
|
|
EOF
|
|
)"
|
|
|
|
for file in "${files[@]}"; do
|
|
echo "[longlines] $file" >&2
|
|
awk "$code" "$file"
|
|
done | (! grep .)
|