|
7 | 7 |
|
8 | 8 | set -ex
|
9 | 9 |
|
10 |
| -ROOT=$(cd "$(dirname "$0")/../.." && pwd) |
11 |
| -[ -z "$NODE" ] && NODE="$ROOT/out/Release/node" |
| 10 | +BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd) |
| 11 | +DEPS_DIR="$BASE_DIR/deps" |
| 12 | +[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node" |
12 | 13 | [ -x "$NODE" ] || NODE=$(command -v node)
|
13 |
| -NPM="$ROOT/deps/npm/bin/npm-cli.js" |
| 14 | +NPM="$BASE_DIR/deps/npm/bin/npm-cli.js" |
14 | 15 |
|
15 | 16 | # shellcheck disable=SC1091
|
16 |
| -. "$ROOT/tools/dep_updaters/utils.sh" |
| 17 | +. "$BASE_DIR/tools/dep_updaters/utils.sh" |
17 | 18 |
|
18 | 19 | NEW_VERSION=$("$NODE" "$NPM" view postject dist-tags.latest)
|
19 | 20 | CURRENT_VERSION=$("$NODE" -p "require('./test/fixtures/postject-copy/node_modules/postject/package.json').version")
|
20 | 21 |
|
21 | 22 | # This function exit with 0 if new version and current version are the same
|
22 | 23 | compare_dependency_version "postject" "$NEW_VERSION" "$CURRENT_VERSION"
|
23 | 24 |
|
24 |
| -cd "$( dirname "$0" )/../.." || exit |
25 |
| -rm -rf test/fixtures/postject-copy |
26 |
| -mkdir test/fixtures/postject-copy |
27 |
| -cd test/fixtures/postject-copy || exit |
| 25 | +echo "Making temporary workspace..." |
| 26 | + |
| 27 | +WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') |
| 28 | + |
| 29 | +cleanup () { |
| 30 | + EXIT_CODE=$? |
| 31 | + [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE" |
| 32 | + exit $EXIT_CODE |
| 33 | +} |
| 34 | + |
| 35 | +trap cleanup INT TERM EXIT |
| 36 | + |
| 37 | +cd "$WORKSPACE" |
| 38 | + |
| 39 | +echo "Installing postject npm package..." |
28 | 40 |
|
29 | 41 | "$NODE" "$NPM" init --yes
|
30 | 42 |
|
31 | 43 | "$NODE" "$NPM" install --no-bin-links --ignore-scripts "postject@$NEW_VERSION"
|
32 | 44 |
|
33 |
| -# TODO(RaisinTen): Replace following with $WORKSPACE |
34 |
| -cd ../../.. |
35 |
| -rm -rf deps/postject |
36 |
| -mkdir deps/postject |
37 |
| -cp test/fixtures/postject-copy/node_modules/postject/LICENSE deps/postject |
38 |
| -cp test/fixtures/postject-copy/node_modules/postject/dist/postject-api.h deps/postject |
| 45 | +echo "Replacing existing postject (except GN build files)" |
| 46 | + |
| 47 | +mv "$DEPS_DIR/postject/"*.gn "$DEPS_DIR/postject/"*.gni "$WORKSPACE/" |
| 48 | +rm -rf "$DEPS_DIR/postject" |
| 49 | +mkdir "$DEPS_DIR/postject" |
| 50 | +mv "$WORKSPACE/"*.gn "$WORKSPACE/"*.gni "$DEPS_DIR/postject" |
| 51 | +mv "$WORKSPACE/node_modules/postject/LICENSE" "$DEPS_DIR/postject" |
| 52 | +mv "$WORKSPACE/node_modules/postject/dist/postject-api.h" "$DEPS_DIR/postject" |
39 | 53 |
|
40 | 54 | # Update the version number on maintaining-dependencies.md
|
41 | 55 | # and print the new version as the last line of the script as we need
|
|
0 commit comments