diff --git a/scripts/release.sh b/scripts/release.sh index 059096d..276048b 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -56,20 +56,18 @@ fi echo "==> Bumping to v$VERSION" -# Root package.json -node -e ' - var fs=require("fs"); var f="package.json"; - var p=JSON.parse(fs.readFileSync(f)); p.version=process.argv[1]; - fs.writeFileSync(f, JSON.stringify(p, null, 2) + "\n"); -' "$VERSION" -echo " updated package.json" +# Bump a package.json "version" field without needing node/jq. +# Only touches the first top-level "version": "…" line, which is the +# canonical location npm puts it. Fragile only if someone hand-wrote +# a nested "version" ABOVE the top-level one. +bump_pkg_version() { + local file="$1" new="$2" + sed -i -E "0,/(\"version\"[[:space:]]*:[[:space:]]*\")[^\"]+(\")/ s//\1${new}\2/" "$file" +} -# Mobile package.json -node -e ' - var fs=require("fs"); var f="mobile/package.json"; - var p=JSON.parse(fs.readFileSync(f)); p.version=process.argv[1]; - fs.writeFileSync(f, JSON.stringify(p, null, 2) + "\n"); -' "$VERSION" +bump_pkg_version package.json "$VERSION" +echo " updated package.json" +bump_pkg_version mobile/package.json "$VERSION" echo " updated mobile/package.json" # Android build.gradle