ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / no / node-gyp / update.sh
blob6b61bacd49f74b2197efd2476927aeda3168ce3f
1 #! /usr/bin/env nix-shell
2 #! nix-shell -i bash -p gnused jq nix-prefetch-github nodejs prefetch-npm-deps wget
4 set -euo pipefail
5 pushd "$(dirname "${BASH_SOURCE[0]}")"
7 version=$(npm view node-gyp version)
9 if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
10 echo "Already up to date!"
11 exit 0
14 sed -i 's#version = "[^"]*"#version = "'"$version"'"#' package.nix
16 src_hash=$(nix-prefetch-github nodejs node-gyp --rev "v$version" | jq --raw-output .hash)
17 sed -i 's#hash = "[^"]*"#hash = "'"$src_hash"'"#' package.nix
19 rm -f package-lock.json package.json
20 wget "https://github.com/nodejs/node-gyp/raw/v$version/package.json"
21 npm i --package-lock-only --ignore-scripts
22 npm_hash=$(prefetch-npm-deps package-lock.json)
23 sed -i 's#npmDepsHash = "[^"]*"#npmDepsHash = "'"$npm_hash"'"#' package.nix
24 rm package.json
26 popd