Skip to content

Commit 163034d

Browse files
committed
Initial commit
0 parents  commit 163034d

File tree

6 files changed

+103
-0
lines changed

6 files changed

+103
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
swift-format
2+
swift-format-*
3+
.DS_Store

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 SeungYeop Yeom
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
default: install
2+
3+
install:
4+
@./install.sh
5+
6+
check:
7+
@./check.sh
8+
9+
.PHONY: install check

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# swift-format-executable

check.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# https://stackoverflow.com/a/5947802
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m'
9+
10+
function __verbose {
11+
echo $*
12+
}
13+
function __success {
14+
echo -e $GREEN$*$NC
15+
}
16+
function __warning {
17+
echo -e $YELLOW$*$NC
18+
}
19+
function __fail {
20+
echo -e $RED$*$NC
21+
}
22+
23+
LATEST_VERSION=$(curl -s -L https://api.github.com/repos/apple/swift-format/releases/latest | sed -n 's/.*"tag_name": "\(.*\)".*/\1/p')
24+
CURRENT_VERSION=$(cat .version)
25+
26+
if [ "$LATEST_VERSION" = "$CURRENT_VERSION" ]; then
27+
__success "The current version is the latest."
28+
exit 0
29+
elif [ "$LATEST_VERSION" '>' "$CURRENT_VERSION" ]; then
30+
__fail "The latest version is not equal to the current version."
31+
exit 1
32+
fi

install.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# https://stackoverflow.com/a/5947802
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m'
9+
10+
function __verbose {
11+
echo $*
12+
}
13+
function __success {
14+
echo -e $GREEN$*$NC
15+
}
16+
function __warning {
17+
echo -e $YELLOW$*$NC
18+
}
19+
function __fail {
20+
echo -e $RED$*$NC
21+
}
22+
23+
# https://stackoverflow.com/a/246128
24+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
25+
cd $SCRIPT_DIR
26+
SWIFT_FORMAT_VERSION=$(cat .version)
27+
28+
__verbose "Installing swift-format..."
29+
rm -rf swift-format
30+
git clone https://github.com/apple/swift-format.git
31+
cd swift-format
32+
git switch --detach "tags/$SWIFT_FORMAT_VERSION"
33+
swift build -c release
34+
cd $SCRIPT_DIR
35+
cp swift-format/.build/release/swift-format ./swift-format-$SWIFT_FORMAT_VERSION
36+
rm -rf swift-format
37+
__success "swift-format is installed."

0 commit comments

Comments
 (0)