Skip to content

Commit 069eec6

Browse files
authored
chore: use clang-format (#232)
1 parent bea626c commit 069eec6

File tree

6 files changed

+29
-2
lines changed

6 files changed

+29
-2
lines changed

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# uses the same styling as V8
2+
BasedOnStyle: Google
3+
DerivePointerAlignment: false
4+
MaxEmptyLinesToKeep: 1

.clang-format-ignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# clang format doesn't work properly with * and **
2+
NativeScript/include/*
3+
NativeScript/include/*/*
4+
NativeScript/include/*/*/*
5+
NativeScript/include/*/*/*/*
6+
NativeScript/include/*/*/*/*/*
7+
NativeScript/ada/*
8+
NativeScript/inspector/third_party/*
9+
NativeScript/inspector/third_party/*/*
10+
NativeScript/inspector/third_party/*/*/*
11+
NativeScript/inspector/third_party/*/*/*/*

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged || echo "Linting failed, verify your clang-format installation"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ To start diving into the v8 iOS runtime make sure you have Xcode and [Homebrew](
55
# Install CMake
66
brew install cmake
77

8+
# (Optional) Install clang-format to format the code
9+
brew install clang-format
10+
811
# To avoid errors, you might need to link cmake to: /usr/local/bin/cmake
912
# xcode doesn't read your profile during the build step, which causes it to ignore the PATH
1013
sudo ln -s /usr/local/bin/cmake $(which cmake)

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"**/*"
2121
],
2222
"scripts": {
23+
"prepare": "husky",
2324
"apply-patches": "./apply_patches.sh",
2425
"build-v8-source": "./build_v8_source.sh",
2526
"build-v8-source-catalyst": "./build_v8_source_catalyst.sh",
@@ -34,6 +35,13 @@
3435
"devDependencies": {
3536
"conventional-changelog-cli": "^2.1.1",
3637
"dayjs": "^1.11.7",
38+
"husky": "^9.0.11",
39+
"lint-staged": "^15.2.7",
3740
"semver": "^7.5.0"
41+
},
42+
"lint-staged": {
43+
"{NativeScript,metadata-generator/src,TestFixtures}/**/*.{h,hpp,c,cpp,mm,m}": [
44+
"clang-format -i"
45+
]
3846
}
3947
}

update_version.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ set -e
33

44
# If a parameter is passed to this script then replace the version in package.json by appending $PACKAGE_VERSION
55
if [ -n "$1" ]; then
6-
sed -i.bak "s/\"version\"[[:space:]]*:[[:space:]]*\"\(.*\)\"[[:space:]]*,/\"version\": \"\1-$PACKAGE_VERSION\",/g" package.json && rm package.json.bak
6+
jq ".version = \"$PACKAGE_VERSION\"" package.json > package.json.tmp && rm package.json && mv package.json.tmp package.json
77
fi
88

99
# Read the version from package.json and replace it inside the NativeScript-Prefix.pch precompiled header
10-
FULL_VERSION=$(sed -nE "s/.*(\"version\"[[:space:]]*:[[:space:]]*\"(.+)\"[[:space:]]*,).*/\2/p" package.json)
10+
FULL_VERSION=$(jq -r .version package.json)
1111
sed -i.bak "s/#define[[:space:]]*NATIVESCRIPT_VERSION[[:space:]]*\"\(.*\)\"/#define NATIVESCRIPT_VERSION \"$FULL_VERSION\"/g" NativeScript/NativeScript-Prefix.pch && rm NativeScript/NativeScript-Prefix.pch.bak

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy