• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3# Shell script to update acorn 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 acorn dist-tags.latest)
16CURRENT_VERSION=$("$NODE" -p "require('./deps/acorn/acorn/package.json').version")
17
18echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
19
20if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
21  echo "Skipped because Acorn is on the latest version."
22  exit 0
23fi
24
25cd "$( dirname "$0" )/../.." || exit
26
27rm -rf deps/acorn/acorn
28
29(
30    rm -rf acorn-tmp
31    mkdir acorn-tmp
32    cd acorn-tmp || exit
33
34    "$NODE" "$NPM" init --yes
35
36    "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "acorn@$NEW_VERSION"
37)
38
39# update version information in src/acorn_version.h
40cat > "$ROOT/src/acorn_version.h" <<EOF
41// This is an auto generated file, please do not edit.
42// Refer to tools/update-acorn.sh
43#ifndef SRC_ACORN_VERSION_H_
44#define SRC_ACORN_VERSION_H_
45#define ACORN_VERSION "$NEW_VERSION"
46#endif  // SRC_ACORN_VERSION_H_
47EOF
48
49mv acorn-tmp/node_modules/acorn deps/acorn
50
51rm -rf acorn-tmp/
52
53echo "All done!"
54echo ""
55echo "Please git add acorn, commit the new version:"
56echo ""
57echo "$ git add -A deps/acorn src/acorn_version.h"
58echo "$ git commit -m \"deps: update acorn to $NEW_VERSION\""
59echo ""
60
61# The last line of the script should always print the new version,
62# as we need to add it to $GITHUB_ENV variable.
63echo "NEW_VERSION=$NEW_VERSION"
64