77
88set -ex
99
10- ROOT =$( cd " $( dirname " $0 " ) /../.." && pwd)
11- [ -z " $NODE " ] && NODE=" $ROOT /out/Release/node"
10+ BASE_DIR =$( cd " $( dirname " $0 " ) /../.." && pwd)
11+ [ -z " $NODE " ] && NODE=" $BASE_DIR /out/Release/node"
1212[ -x " $NODE " ] || NODE=$( command -v node)
13- NPM=" $ROOT /deps/npm/bin/npm-cli.js"
13+ NPM=" $BASE_DIR /deps/npm/bin/npm-cli.js"
14+ DEPS_DIR=" $BASE_DIR /deps"
1415
1516# shellcheck disable=SC1091
16- . " $ROOT /tools/dep_updaters/utils.sh"
17+ . " $BASE_DIR /tools/dep_updaters/utils.sh"
1718
1819NEW_VERSION=$( " $NODE " " $NPM " view acorn dist-tags.latest)
19- CURRENT_VERSION=$( " $NODE " -p " require( './deps/acorn/acorn/package.json'). version" )
20+ CURRENT_VERSION=$( " $NODE " " $NPM " --prefix ' ./deps/acorn/acorn/' pkg get version)
2021
2122# This function exit with 0 if new version and current version are the same
2223compare_dependency_version " acorn" " $NEW_VERSION " " $CURRENT_VERSION "
2324
2425cd " $( dirname " $0 " ) /../.." || exit
2526
26- rm -rf deps/acorn/acorn
27+ echo " Making temporary workspace... "
2728
28- (
29- rm -rf acorn-tmp
30- mkdir acorn-tmp
31- cd acorn-tmp || exit
29+ WORKSPACE=$( mktemp -d 2> /dev/null || mktemp -d -t ' tmp' )
3230
33- " $NODE " " $NPM " init --yes
31+ cleanup () {
32+ EXIT_CODE=$?
33+ [ -d " $WORKSPACE " ] && rm -rf " $WORKSPACE "
34+ exit $EXIT_CODE
35+ }
3436
35- " $NODE " " $NPM " install --global-style --no-bin-links --ignore-scripts " acorn@$NEW_VERSION "
36- )
37+ trap cleanup INT TERM EXIT
38+
39+ cd " $WORKSPACE "
40+
41+ echo " Fetching acorn source archive..."
42+
43+ " $NODE " " $NPM " pack " acorn@$NEW_VERSION "
44+
45+ ACORN_TGZ=" acorn-$NEW_VERSION .tgz"
46+
47+ log_and_verify_sha256sum " acorn" " $ACORN_TGZ "
48+
49+ rm -r " $DEPS_DIR /acorn/acorn" /*
50+
51+ tar -xf " $ACORN_TGZ "
52+
53+ mv package/* " $DEPS_DIR /acorn/acorn"
3754
3855# update version information in src/acorn_version.h
39- cat > " $ROOT /src/acorn_version.h" << EOF
56+ cat > " $BASE_DIR /src/acorn_version.h" << EOF
4057// This is an auto generated file, please do not edit.
4158// Refer to tools/dep_updaters/update-acorn.sh
4259#ifndef SRC_ACORN_VERSION_H_
@@ -45,9 +62,14 @@ cat > "$ROOT/src/acorn_version.h" <<EOF
4562#endif // SRC_ACORN_VERSION_H_
4663EOF
4764
48- mv acorn-tmp/node_modules/acorn deps/acorn
49-
50- rm -rf acorn-tmp/
65+ echo " All done!"
66+ echo " "
67+ echo " Please git add acorn, commit the new version:"
68+ echo " "
69+ echo " $ git add -A deps/acorn/acorn"
70+ echo " $ git add $BASE_DIR /src/acorn_version.h"
71+ echo " $ git commit -m \" deps: update acorn to $NEW_VERSION \" "
72+ echo " "
5173
5274# Update the version number on maintaining-dependencies.md
5375# and print the new version as the last line of the script as we need
0 commit comments