Skip to content

Commit 3fee055

Browse files
committed
chore: exclude files based on .gitignore
1 parent 4f4376b commit 3fee055

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

script/zip.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ FOLDER=$(
66
)
77
TARGET_PATH="${FOLDER}/aaa"
88

9-
COPYFILE_DISABLE=1 tar -zcvf ${TARGET_PATH} \
10-
--exclude=dist*/ \
11-
--exclude=.git/ \
12-
--exclude=package-lock.json \
13-
--exclude=node_modules \
14-
--exclude=firefox_dev*/ \
15-
--exclude=market_packages \
16-
--exclude=aaa \
17-
./
9+
EXCLUDE_ARGS=""
10+
11+
if [ -f "${FOLDER}/.gitignore" ]; then
12+
while IFS= read -r line || [ -n "$line" ]; do
13+
[[ -z "$line" || "$line" =~ ^# ]] && continue
14+
line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
15+
[ -z "$line" ] && continue
16+
17+
pattern="${line#/}"
18+
EXCLUDE_ARGS="${EXCLUDE_ARGS} --exclude=${pattern}"
19+
done < "${FOLDER}/.gitignore"
20+
fi
21+
22+
EXCLUDE_ARGS="${EXCLUDE_ARGS} --exclude=.git"
23+
24+
cd "${FOLDER}"
25+
COPYFILE_DISABLE=1 tar -zcf ${TARGET_PATH} ${EXCLUDE_ARGS} ./

0 commit comments

Comments
 (0)