mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	This makes curl exit with nonzero status on HTTP 4xx/5xx errors. Signed-off-by: Anders Kaseorg <anders@zulip.com>
		
			
				
	
	
		
			29 lines
		
	
	
		
			885 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			885 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
set -euo pipefail
 | 
						|
 | 
						|
version=1.22.10
 | 
						|
sha256=05a22fff30d7d8e8005bed277bf20d55111ba2bed65a6b91a0fcd1307b71fd8d
 | 
						|
tarball="yarn-$version.tgz"
 | 
						|
 | 
						|
check_version() {
 | 
						|
    # Reading the version of Yarn from its package.json is much faster
 | 
						|
    # than running yarn --version.
 | 
						|
    link="$(command -v yarn)" \
 | 
						|
        && bin="$(readlink -f "$link")" \
 | 
						|
        && current_version="$(jq -r '.version' "${bin%/*/*}/package.json")" \
 | 
						|
        && [ "$current_version" = "$version" ]
 | 
						|
}
 | 
						|
 | 
						|
if ! check_version; then
 | 
						|
    tmpdir="$(mktemp -d)"
 | 
						|
    trap 'rm -r "$tmpdir"' EXIT
 | 
						|
    cd "$tmpdir"
 | 
						|
    curl -fLO "https://registry.npmjs.org/yarn/-/$tarball"
 | 
						|
    sha256sum -c <<<"$sha256 $tarball"
 | 
						|
    rm -rf /srv/zulip-yarn
 | 
						|
    mkdir /srv/zulip-yarn
 | 
						|
    tar -xzf "$tarball" --no-same-owner --strip-components=1 -C /srv/zulip-yarn
 | 
						|
    ln -nsf /srv/zulip-yarn/bin/yarn /usr/bin/yarn
 | 
						|
    check_version
 | 
						|
fi
 |