Skip to content

Commit

Permalink
build: remove test:pack test
Browse files Browse the repository at this point in the history
  • Loading branch information
broofa committed Jan 9, 2025
1 parent 0a26361 commit bf6ce5f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 51 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ jobs:
- run: npm ci
- run: npm run test
- run: npm run test:node
- run: npm run test:pack
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx --no-install lint-staged
npm test
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@
"examples:node:jest:test": "cd examples/node-jest && npm install && npm test",
"lint": "npm run eslint:check && npm run prettier:check",
"md": "runmd --watch --output=README.md README_js.md",
"prepack": "npm run build",
"prepack": "npm run build -- --no-pack",
"prepare": "husky",
"prepublishOnly": "npm run build",
"pretest:benchmark": "npm run build",
"pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
"pretest:node": "npm run build",
Expand All @@ -106,7 +107,6 @@
"test:benchmark": "cd examples/benchmark && HUSKY=0 npm install && npm test",
"test:browser": "wdio run ./wdio.conf.js",
"test:node": "npm-run-all --parallel examples:node:**",
"test:pack": "./scripts/testpack.sh",
"test:watch": "node --test --enable-source-maps --watch dist/esm/test/*.js",
"test": "node --test --enable-source-maps dist/esm/test/*.js"
},
Expand Down
31 changes: 17 additions & 14 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ mkdir -p "$BUILD_DIR"
for MODULE_TYPE in esm cjs; do
echo "Building ${MODULE_TYPE}"

MODULE_DIST_DIR="$DIST_DIR/${MODULE_TYPE}"
BROWSER_DIR="$DIST_DIR/${MODULE_TYPE}-browser"
NODE_DIST_DIR="$DIST_DIR/${MODULE_TYPE}"
BROWSER_DIST_DIR="$DIST_DIR/${MODULE_TYPE}-browser"

tsc -p tsconfig.${MODULE_TYPE}.json

# Clone files for browser builds
cp -pr ${MODULE_DIST_DIR} ${BROWSER_DIR}
cp -pr ${NODE_DIST_DIR} ${BROWSER_DIST_DIR}

# Remove browser files from non-browser builds
for FILE in ${MODULE_DIST_DIR}/*-browser*;do
for FILE in ${NODE_DIST_DIR}/*-browser*;do
rm -f $FILE
done

# Move browser files into place for browser builds
(
# Temporarily cd into BROWSER_DIR to avoid having to deal with "-browser"
# appearing in both the dir name and file name of FILE's full path
cd ${BROWSER_DIR}
# Temporarily cd into BROWSER_DIST_DIR to avoid having to deal with
# "-browser" appearing in both the dir name and file name of FILE's full
# path
cd ${BROWSER_DIST_DIR}

for FILE in *-browser*;do
mv $FILE ${FILE/-browser/}
Expand All @@ -56,17 +57,19 @@ for MODULE_TYPE in esm cjs; do
# esm/cjs-specific logic
if [ "$MODULE_TYPE" = "esm" ]; then
# ESM: copy bin files to dist
cp -pr "$DIST_DIR/../src/bin" "$MODULE_DIST_DIR"
cp -pr "$DIST_DIR/../src/bin" "$NODE_DIST_DIR"
else
# CJS: Add package.json that specifies type: commonjs
echo "{\"type\":\"commonjs\"}" > "$MODULE_DIST_DIR/package.json"
echo "{\"type\":\"commonjs\"}" > "$BROWSER_DIR/package.json"
echo "{\"type\":\"commonjs\"}" > "$NODE_DIST_DIR/package.json"
echo "{\"type\":\"commonjs\"}" > "$BROWSER_DIST_DIR/package.json"
fi
done

# Create tarball for local installation (in tests and examples)
echo "Packing tarball"
npm pack --ignore-scripts --pack-destination "$BUILD_DIR" > /dev/null 2>&1
mv $BUILD_DIR/*.tgz $BUILD_DIR/uuid.tgz
if [ "${1-}" != "--no-pack" ]; then
# Create tarball for local installation (in tests and examples)
echo "Packing tarball"
npm pack --pack-destination "$BUILD_DIR" > /dev/null 2>&1
mv $BUILD_DIR/*.tgz $BUILD_DIR/uuid.tgz
fi

echo "-- fin --"
33 changes: 0 additions & 33 deletions scripts/testpack.sh

This file was deleted.

0 comments on commit bf6ce5f

Please sign in to comment.