fix: reconcile latest.json version compare node script
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,12 +15,22 @@ fi
|
||||
VERSION="$(node -p "require('$CONF').version" 2>/dev/null || echo '0.1.0')"
|
||||
LATEST_JSON="$UPDATES_DIR/latest.json"
|
||||
if [[ -f "$LATEST_JSON" ]]; then
|
||||
EXISTING="$(node -p "
|
||||
const fs=require('fs'); const v=require('$LATEST_JSON').version||'0.0.0';
|
||||
const c='$VERSION'.split('.').map(Number); const e=v.split('.').map(Number);
|
||||
for (let i=0;i<3;i++){ if((e[i]||0)>(c[i]||0)){ console.log(v); process.exit(0);} if((e[i]||0)<(c[i]||0)) break;}
|
||||
console.log('$VERSION');
|
||||
" 2>/dev/null || echo "$VERSION")"
|
||||
EXISTING="$(node <<NODE
|
||||
const fs = require('fs');
|
||||
const confV = '$VERSION';
|
||||
let existing = '0.0.0';
|
||||
try { existing = JSON.parse(fs.readFileSync('$LATEST_JSON', 'utf8')).version || '0.0.0'; } catch {}
|
||||
const cmp = (a, b) => {
|
||||
const pa = a.split('.').map(Number), pb = b.split('.').map(Number);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const d = (pa[i] || 0) - (pb[i] || 0);
|
||||
if (d !== 0) return d;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
console.log(cmp(existing, confV) > 0 ? existing : confV);
|
||||
NODE
|
||||
)"
|
||||
VERSION="$EXISTING"
|
||||
fi
|
||||
NOTES="${DESKTOP_RELEASE_NOTES:-GoldenChart Desktop $VERSION}"
|
||||
|
||||
Reference in New Issue
Block a user