This repository was archived by the owner on Feb 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # PURPOSE
4+ # =======
5+ #
6+ # This script is to be run when editor finishes editing a file.
7+ #
8+ # INSTALLATION
9+ # ============
10+ #
11+ # Visual Studio Code
12+ # ------------------
13+ #
14+ # 1. Install "Run On Save" extension
15+ # - Marketplace ID: pucelle.run-on-save
16+ # - GitHub Repo: https://github.com/pucelle/vscode-run-on-save
17+ #
18+ # 2. Add the following section to your `settings.json`:
19+ # "runOnSave.commands": [
20+ # {
21+ # "match": ".*",
22+ # "command": "sh -c 'if [ -x ./run-on-save ]; then FILE=${file} ./run-on-save; fi'",
23+ # "runIn": "backend",
24+ # }
25+ # ]
26+
27+ set -o errexit -o pipefail -o nounset
28+
29+ # TASK: Use sane-fmt to format TypeScript/JavaScript file
30+ # Recommend: Install native sane-fmt for good performance (https://github.com/sane-fmt/sane-fmt)
31+ for ext in js ts jsx tsx; do
32+ if [[ " $FILE " == * .$ext && " $FILE " != * node_modules* ]]; then
33+ if which sane-fmt & > /dev/null; then
34+ echo " Run sane-fmt on $FILE "
35+ sane-fmt --color=never --write " $FILE "
36+ else
37+ echo ' Using WebAssembly implementation of sane-fmt'
38+ echo ' Recommend: Install native version from https://github.com/sane-fmt/sane-fmt'
39+ pnpm run sane-fmt:fix -- --color=never --hide-passed
40+ fi
41+ break
42+ fi
43+ done
You can’t perform that action at this time.
0 commit comments