From d1dd94d04f3835bd00241c39555e32cba5ca7b4a Mon Sep 17 00:00:00 2001 From: Robert Kieffer Date: Fri, 1 Dec 2023 10:45:28 -0800 Subject: [PATCH] ci: integration test of published tarball (#293) --- package.json | 2 +- test/exports_test.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 test/exports_test.sh diff --git a/package.json b/package.json index 887a798..a3421fd 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "prepare": "npm run build", "prepublishOnly": "npm run build && npm run build:types", "release": "# `standard-version --dry-run --prerelease` is the command you're after", - "test": "node --test", + "test": "node --test && ./test/exports_test.sh", "test:watch": "clear && node --enable-source-maps --test --watch test" }, "keywords": [ diff --git a/test/exports_test.sh b/test/exports_test.sh new file mode 100755 index 0000000..02ee283 --- /dev/null +++ b/test/exports_test.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +TESTDIR="/tmp/mime_test" + +echo -e "\n\nExports test" +\rm -fr $TESTDIR +mkdir -p $TESTDIR + +echo "... building tarball" +cd $SCRIPT_DIR/.. +npm pack --silent --pack-destination $TESTDIR > /dev/null 2>&1 + +echo ... installing tarball +cd $TESTDIR +npm install --silent mime*.tgz + +echo "... testing imports" +node --input-type=module - << EOF + import mime from "mime"; + import mimelite from "mime/lite"; + + console.log('okay'); +EOF +