Skip to content

Commit 18af593

Browse files
committed
ci(package-prepare): make initialization non-interactive for GitHub workflows
1 parent baa6039 commit 18af593

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
node-version-file: "package.json"
1717
cache: "npm"
1818

19+
- run: touch .ci_mode
20+
1921
- name: Install dependencies
2022
run: npm ci
2123

.github/workflows/slither.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717

18+
- run: touch .ci_mode
19+
1820
- name: Run Slither
1921
uses: crytic/[email protected]

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
node-version-file: "package.json"
3737
cache: "npm"
3838

39+
- run: touch .ci_mode
40+
3941
- name: Install dependencies
4042
run: npm ci
4143

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"lint:sol": "npx hardhat check && npx prettier --check \"contracts/**/*.sol\"",
3636
"lint:sol:fix": "npx solhint --fix \"contracts/**/*.sol\" && npx prettier --write \"contracts/**/*.sol\"",
3737
"lint:workflow": "npx prettier -u --check \"*\" && npx eslint .; [ ! -f .audit_mode ] && npx hardhat check",
38-
"prepare": "husky && bash scripts/commands/initialize.sh"
38+
"prepare": "husky && mkdir -p contracts test && bash scripts/commands/initialize_template.sh"
3939
},
4040
"engines": {
4141
"node": ">=21.2.0 || >=20.11.0 <21.0.0",

scripts/commands/initialize.sh renamed to scripts/commands/initialize_template.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
set -eo pipefail
44

5-
echo
6-
echo "Initializing a template..."
5+
if [ -f ".ci_mode" ]; then
6+
exit 0
7+
fi
78

8-
INIT_FILE_PATH="./scripts/commands/.initialized"
9+
INIT_FILE_PATH="./scripts/commands/.initialized_template"
910

1011
if [ ! -f "$INIT_FILE_PATH" ]; then
11-
mkdir -p contracts test
12+
echo
13+
echo "Initializing the template..."
1214

1315
rm -f LICENSE
1416

@@ -30,8 +32,6 @@ if [ ! -f "$INIT_FILE_PATH" ]; then
3032
echo "Do not forget to push this commit."
3133
echo
3234
fi
33-
else
34-
echo "The project has already been initialized."
3535
fi
3636

3737
echo

0 commit comments

Comments
 (0)