Better way to query pkgver with curl from package.json

anyone know a better way to query a pkgver from a json file like this with curl:

pkgver=$(curl https://raw.githubusercontent.com/microsoft/vscode/main/package.json -o package.json && awk '/version/{gsub(/("|",)/,"",$2);print $2}' package.json)

You could use jq to interpret the JSON file:

pkgver="$(curl https://raw.githubusercontent.com/microsoft/vscode/main/package.json | jq -r '.version')"
1 Like

Thank you, but I get this on the build:

build upstream vscode-dev-oss on github with manjaro-chrootbuild

/build/code-git/PKGBUILD: line 15: jq: command not found

[473](https://github.com/pheiduck/code-git/runs/4997723267?check_suite_focus=true#step:7:473) % Total % Received % Xferd Average Speed Time Time Time Current

[474](https://github.com/pheiduck/code-git/runs/4997723267?check_suite_focus=true#step:7:474) Dload Upload Total Spent Left Speed

[476](https://github.com/pheiduck/code-git/runs/4997723267?check_suite_focus=true#step:7:476)

[477](https://github.com/pheiduck/code-git/runs/4997723267?check_suite_focus=true#step:7:477) 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

[478](https://github.com/pheiduck/code-git/runs/4997723267?check_suite_focus=true#step:7:478) 54 9113 54 4995 0 0 168k 0 --:--:-- --:--:-- --:--:-- 174k

[479](https://github.com/pheiduck/code-git/runs/4997723267?check_suite_focus=true#step:7:479)curl: (23) Failure writing output to destination

[478](https://github.com/pheiduck/code-git/runs/4997723267?check_suite_focus=true#step:7:478)==> ERROR: pkgver is not allowed to be empty.

[480](https://github.com/pheiduck/code-git/runs/4997723267?check_suite_focus=true#step:7:480)==> ERROR: Building package [code-git] failed.

Found a bit ugly way to install jq from there, but it work:

@pheiduck What about this? This is a better approach as python is already installed on every system:

pkgver="$(curl -s "https://raw.githubusercontent.com/microsoft/vscode/main/package.json" | python3 -c "import sys, json; print(json.load(sys.stdin)['version'])")"
1 Like

will try, hope the latest step will pass now.:

After fixing the CI its working now to build on github:
Thank you @ishaan2479

1 Like

query the electron version as well with curl and awk here

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.