mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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>
This commit is contained in:
@@ -11,16 +11,17 @@ if [ "$#" -le 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WORKSPACE="$TMPDIR"update-npm-$NPM_VERSION/
|
||||
|
||||
if [ -d "$WORKSPACE" ]; then
|
||||
echo "Cleaning up old workspace"
|
||||
rm -rf "$WORKSPACE"
|
||||
fi
|
||||
|
||||
echo "Making temporary workspace"
|
||||
|
||||
mkdir -p "$WORKSPACE"
|
||||
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
|
||||
|
||||
cleanup () {
|
||||
EXIT_CODE=$?
|
||||
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
|
||||
exit $EXIT_CODE
|
||||
}
|
||||
|
||||
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!"
|
||||
|
||||
Reference in New Issue
Block a user