Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44cd7a6

Browse filesBrowse files
perf: faster formatting
1 parent ea703c8 commit 44cd7a6
Copy full SHA for 44cd7a6

File tree

Expand file treeCollapse file tree

1 file changed

+40
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+40
-0
lines changed
Open diff view settings
Collapse file

‎scripts/fast-format‎

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
echo "Script started with $# arguments"
6+
echo "Arguments: $*"
7+
echo "Script location: $(dirname "$0")"
8+
9+
cd "$(dirname "$0")/.."
10+
echo "Changed to directory: $(pwd)"
11+
12+
if [ $# -eq 0 ]; then
13+
echo "Usage: $0 <file-with-paths> [additional-formatter-args...]"
14+
echo "The file should contain one file path per line"
15+
exit 1
16+
fi
17+
18+
FILE_LIST="$1"
19+
20+
echo "Looking for file: $FILE_LIST"
21+
22+
if [ ! -f "$FILE_LIST" ]; then
23+
echo "Error: File '$FILE_LIST' not found"
24+
exit 1
25+
fi
26+
27+
echo "==> Running eslint --fix"
28+
ESLINT_FILES="$(grep '\.ts$' "$FILE_LIST" || true)"
29+
if ! [ -z "$ESLINT_FILES" ]; then
30+
echo "$ESLINT_FILES" | ESLINT_USE_FLAT_CONFIG="false" xargs ./node_modules/.bin/eslint --cache --fix
31+
fi
32+
33+
echo "==> Running prettier --write"
34+
# format things eslint didn't
35+
PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)"
36+
if ! [ -z "$PRETTIER_FILES" ]; then
37+
echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \
38+
--write --cache --cache-strategy metadata \
39+
'!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs'
40+
fi

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.