Fix lockfile script for Alpine Linux compatibility
ci/woodpecker/push/woodpecker Pipeline failed
Details
ci/woodpecker/push/woodpecker Pipeline failed
Details
- Change shebang from bash to sh (POSIX-compliant) - Auto-detect hash command (sha256sum/shasum) - Use sh explicitly in CI step
This commit is contained in:
parent
a4b6db6a22
commit
b70949e904
|
|
@ -35,7 +35,7 @@ steps:
|
||||||
- echo "nameserver 1.1.1.1" > /etc/resolv.conf
|
- echo "nameserver 1.1.1.1" > /etc/resolv.conf
|
||||||
- echo "nameserver 1.0.0.1" >> /etc/resolv.conf
|
- echo "nameserver 1.0.0.1" >> /etc/resolv.conf
|
||||||
- chmod +x scripts/refresh-lockfile.sh
|
- chmod +x scripts/refresh-lockfile.sh
|
||||||
- ./scripts/refresh-lockfile.sh --check
|
- sh scripts/refresh-lockfile.sh --check
|
||||||
when:
|
when:
|
||||||
branch: main
|
branch: main
|
||||||
event: [push, pull_request]
|
event: [push, pull_request]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# Refresh package-lock.json to apply npm overrides and get latest compatible versions
|
# Refresh package-lock.json to apply npm overrides and get latest compatible versions
|
||||||
# This ensures security patches from overrides are actually applied
|
# This ensures security patches from overrides are actually applied
|
||||||
#
|
#
|
||||||
|
|
@ -17,10 +17,21 @@ fi
|
||||||
|
|
||||||
echo "🔄 Refreshing package-lock.json..."
|
echo "🔄 Refreshing package-lock.json..."
|
||||||
|
|
||||||
|
# Detect hash command (sha256sum on Linux, shasum on macOS)
|
||||||
|
HASH_CMD=""
|
||||||
|
if command -v sha256sum >/dev/null 2>&1; then
|
||||||
|
HASH_CMD="sha256sum"
|
||||||
|
elif command -v shasum >/dev/null 2>&1; then
|
||||||
|
HASH_CMD="shasum -a 256"
|
||||||
|
else
|
||||||
|
echo "❌ Error: Neither sha256sum nor shasum found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Backup current lock file hash for comparison
|
# Backup current lock file hash for comparison
|
||||||
OLD_HASH=""
|
OLD_HASH=""
|
||||||
if [ -f package-lock.json ]; then
|
if [ -f package-lock.json ]; then
|
||||||
OLD_HASH=$(shasum -a 256 package-lock.json | cut -d' ' -f1)
|
OLD_HASH=$($HASH_CMD package-lock.json | cut -d' ' -f1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean and regenerate
|
# Clean and regenerate
|
||||||
|
|
@ -34,7 +45,7 @@ else
|
||||||
npm install
|
npm install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NEW_HASH=$(shasum -a 256 package-lock.json | cut -d' ' -f1)
|
NEW_HASH=$($HASH_CMD package-lock.json | cut -d' ' -f1)
|
||||||
|
|
||||||
if [ "$OLD_HASH" = "$NEW_HASH" ]; then
|
if [ "$OLD_HASH" = "$NEW_HASH" ]; then
|
||||||
echo "✅ package-lock.json is up to date"
|
echo "✅ package-lock.json is up to date"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue