• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3# Shell script to update postject in the source tree to the latest release.
4
5# This script must be in the tools directory when it runs because it uses the
6# script source file path to determine directories to work in.
7
8set -ex
9
10ROOT=$(cd "$(dirname "$0")/../.." && pwd)
11[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
12[ -x "$NODE" ] || NODE=$(command -v node)
13NPM="$ROOT/deps/npm/bin/npm-cli.js"
14
15NEW_VERSION=$("$NODE" "$NPM" view postject dist-tags.latest)
16CURRENT_VERSION=$("$NODE" -p "require('./test/fixtures/postject-copy/node_modules/postject/package.json').version")
17
18echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
19
20if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
21  echo "Skipped because Postject is on the latest version."
22  exit 0
23fi
24
25cd "$( dirname "$0" )/../.." || exit
26rm -rf test/fixtures/postject-copy
27mkdir test/fixtures/postject-copy
28cd test/fixtures/postject-copy || exit
29
30"$NODE" "$NPM" init --yes
31
32"$NODE" "$NPM" install --no-bin-links --ignore-scripts "postject@$NEW_VERSION"
33
34# TODO(RaisinTen): Replace following with $WORKSPACE
35cd ../../..
36rm -rf deps/postject
37mkdir deps/postject
38cp test/fixtures/postject-copy/node_modules/postject/LICENSE deps/postject
39cp test/fixtures/postject-copy/node_modules/postject/dist/postject-api.h deps/postject
40
41# The last line of the script should always print the new version,
42# as we need to add it to $GITHUB_ENV variable.
43echo "NEW_VERSION=$NEW_VERSION"
44