Skip to content

Commit

Permalink
chore: use mktemp and trap
Browse files Browse the repository at this point in the history
  • Loading branch information
broofa committed Jul 21, 2024
1 parent 9b3b594 commit 05bcf23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/node-esmodules/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
v6ToV1 as uuidv6ToV1,
v7 as uuidv7,
} from 'uuid';
import pkg from 'uuid/package.json' assert { type: 'json' };
import pkg from 'uuid/package.json' with { type: 'json' };

console.log('uuidv1()', uuidv1());

Expand Down
7 changes: 5 additions & 2 deletions scripts/testpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
ROOT="$(pwd)/$(dirname "$0")/.."
cd "$ROOT" || exit 1

TEST_DIR=/tmp/test-pack
TEST_DIR=$(mktemp -d)

TARBALL=${TEST_DIR}/uuid.tgz

mkdir -p ${TEST_DIR}
Expand All @@ -13,7 +14,7 @@ mkdir -p ${TEST_DIR}
npm pack --pack-destination=${TEST_DIR}

# Set up a test project in the test directory
cd ${TEST_DIR}
pushd ${TEST_DIR}
npm init -y
cp ${ROOT}/examples/node-commonjs/example.js commonjs.js
cp ${ROOT}/examples/node-esmodules/example.mjs esmodules.mjs
Expand All @@ -30,3 +31,5 @@ node esmodules.mjs
# not supported in earlier versions. Therefore we restrict the ESM test to more recent versions of
# Node.js:
( node --version | grep -vq 'v16' ) || ( node --experimental-json-modules esmodules-package.mjs )

trap 'popd && rm -rf $TEST_DIR' EXIT

0 comments on commit 05bcf23

Please sign in to comment.