diff options
author | Luigi Pinca <luigipinca@gmail.com> | 2021-04-27 11:52:02 +0300 |
---|---|---|
committer | Luigi Pinca <luigipinca@gmail.com> | 2021-05-03 15:49:52 +0300 |
commit | 63c9b5ba9b022d753194b11b4ad467d8105b8b82 (patch) | |
tree | 1a0ed9b6c0e9fb158cfdaa8a23b30419e51e72a9 /tools | |
parent | 2c0fd32db35761f40a65b3af52f0b338874caf49 (diff) |
tools: use mktemp to create the workspace directory
On some platforms, the TMPDIR environment variable is not set.
PR-URL: https://github.com/nodejs/node/pull/38432
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/update-npm.sh | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/tools/update-npm.sh b/tools/update-npm.sh index a203bba3623..d58b325b77f 100755 --- a/tools/update-npm.sh +++ b/tools/update-npm.sh @@ -11,16 +11,17 @@ if [ "$#" -le 0 ]; then exit 1 fi -WORKSPACE="$TMPDIR"update-npm-$NPM_VERSION/ +echo "Making temporary workspace" -if [ -d "$WORKSPACE" ]; then - echo "Cleaning up old workspace" - rm -rf "$WORKSPACE" -fi +WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') -echo "Making temporary workspace" +cleanup () { + EXIT_CODE=$? + [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE" + exit $EXIT_CODE +} -mkdir -p "$WORKSPACE" +trap cleanup INT TERM EXIT cd "$WORKSPACE" @@ -39,11 +40,7 @@ rm -rf npm/ echo "Copying new npm" -tar zxf "$WORKSPACE"cli/release/npm-"$NPM_VERSION".tgz - -echo "Deleting temporary workspace" - -rm -rf "$WORKSPACE" +tar zxf "$WORKSPACE"/cli/release/npm-"$NPM_VERSION".tgz echo "" echo "All done!" |