Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 499da2d

Browse filesBrowse files
lpincatargos
authored andcommitted
tools: use mktemp to create the workspace directory
On some platforms, the TMPDIR environment variable is not set. PR-URL: #38432 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 0e446d6 commit 499da2d
Copy full SHA for 499da2d

File tree

Expand file treeCollapse file tree

1 file changed

+9
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-12
lines changed
Open diff view settings
Collapse file

‎tools/update-npm.sh‎

Copy file name to clipboardExpand all lines: tools/update-npm.sh
+9-12Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ if [ "$#" -le 0 ]; then
1111
exit 1
1212
fi
1313

14-
WORKSPACE="$TMPDIR"update-npm-$NPM_VERSION/
14+
echo "Making temporary workspace"
1515

16-
if [ -d "$WORKSPACE" ]; then
17-
echo "Cleaning up old workspace"
18-
rm -rf "$WORKSPACE"
19-
fi
16+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
2017

21-
echo "Making temporary workspace"
18+
cleanup () {
19+
EXIT_CODE=$?
20+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
21+
exit $EXIT_CODE
22+
}
2223

23-
mkdir -p "$WORKSPACE"
24+
trap cleanup INT TERM EXIT
2425

2526
cd "$WORKSPACE"
2627

@@ -39,11 +40,7 @@ rm -rf npm/
3940

4041
echo "Copying new npm"
4142

42-
tar zxf "$WORKSPACE"cli/release/npm-"$NPM_VERSION".tgz
43-
44-
echo "Deleting temporary workspace"
45-
46-
rm -rf "$WORKSPACE"
43+
tar zxf "$WORKSPACE"/cli/release/npm-"$NPM_VERSION".tgz
4744

4845
echo ""
4946
echo "All done!"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.