Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: use mktemp to create the workspace directory #38432

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 9 additions & 12 deletions tools/update-npm.sh
Expand Up @@ -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"

Expand All @@ -40,11 +41,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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this comes from the previous implementation, but the use of the quotes seems… weird. I think we're supposed to put the whole argument inside one string.

Suggested change
tar zxf "$WORKSPACE"/cli/release/npm-"$NPM_VERSION".tgz
tar zxf "${WORKSPACE}/cli/release/npm-${NPM_VERSION}.tgz"

or

Suggested change
tar zxf "$WORKSPACE"/cli/release/npm-"$NPM_VERSION".tgz
tar zxf "$WORKSPACE/cli/release/npm-$NPM_VERSION.tgz"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in multiple places so I would not change it here. I think it's better to use another PR/commit to eventually make it consistent in the whole script.


echo ""
echo "All done!"
Expand Down