Skip to content

Commit 9f5b888

Browse files
committed
build: remove test:pack test
1 parent 0a26361 commit 9f5b888

File tree

13 files changed

+54
-137
lines changed

13 files changed

+54
-137
lines changed

.github/workflows/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ jobs:
3535
- run: npm ci
3636
- run: npm run test
3737
- run: npm run test:node
38-
- run: npm run test:pack

.husky/pre-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npx --no-install lint-staged
1+
npm test

examples/benchmark/package-lock.json

+14-71
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/benchmark/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"build": "true",
77
"start": "npm run build && npx http-server . -o",
8+
"pretest": "HUSKY=0 npm install",
89
"test": "node node.js"
910
},
1011
"dependencies": {

examples/browser-rollup/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
6-
"build": "rm -rf dist && rollup -c",
6+
"build": "npm install && rm -rf dist && rollup -c",
77
"start": "npm run build && npx http-server . -o"
88
},
99
"dependencies": {

examples/browser-webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
6-
"build": "rm -rf dist && webpack",
6+
"build": "npm install && rm -rf dist && webpack",
77
"start": "npm run build && npx http-server . -o"
88
},
99
"dependencies": {

examples/node-commonjs/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
6+
"pretest": "npm install",
67
"test": "node example.js"
78
},
89
"dependencies": {

examples/node-esmodules/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"test:package": "( node --version | grep -vq 'v16' ) || ( node --experimental-json-modules package.mjs )",
77
"test:example": "node example.mjs",
8+
"pretest": "npm install",
89
"test": "npm-run-all test:*"
910
},
1011
"dependencies": {

examples/node-jest/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
6+
"pretest": "npm install",
67
"test": "jest"
78
},
89
"dependencies": {

examples/node-webpack/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"scripts": {
66
"build": "rm -rf dist && webpack",
7+
"pretest": "npm install",
78
"test": "npm run build && node dist/v1.js && node dist/v4.js && node dist/v7.js && node dist/all.js"
89
},
910
"dependencies": {

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,26 @@
8787
"docs": "npm run build && npx runmd --output=README.md README_js.md",
8888
"eslint:check": "eslint src/ test/ examples/ *.[jt]s",
8989
"eslint:fix": "eslint --fix src/ test/ examples/ *.[jt]s",
90-
"examples:browser:rollup:build": "cd examples/browser-rollup && npm install && npm run build",
91-
"examples:browser:webpack:build": "cd examples/browser-webpack && npm install && npm run build",
92-
"examples:node:commonjs:test": "cd examples/node-commonjs && npm install && npm test",
93-
"examples:node:esmodules:test": "cd examples/node-esmodules && npm install && npm test",
94-
"examples:node:jest:test": "cd examples/node-jest && npm install && npm test",
90+
"examples:browser:rollup:build": "cd examples/browser-rollup && npm run build",
91+
"examples:browser:webpack:build": "cd examples/browser-webpack && npm run build",
92+
"examples:node:commonjs:test": "cd examples/node-commonjs && npm test",
93+
"examples:node:esmodules:test": "cd examples/node-esmodules && npm test",
94+
"examples:node:jest:test": "cd examples/node-jest && npm test",
9595
"lint": "npm run eslint:check && npm run prettier:check",
9696
"md": "runmd --watch --output=README.md README_js.md",
97-
"prepack": "npm run build",
97+
"prepack": "npm run build -- --no-pack",
9898
"prepare": "husky",
99+
"prepublishOnly": "npm run build",
99100
"pretest:benchmark": "npm run build",
100-
"pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
101+
"pretest:browser": "./scripts/iodd && npm run build && npm-run-all examples:browser:**",
101102
"pretest:node": "npm run build",
102103
"pretest": "npm run build",
103104
"prettier:check": "prettier --check .",
104105
"prettier:fix": "prettier --write .",
105106
"release": "standard-version --no-verify",
106-
"test:benchmark": "cd examples/benchmark && HUSKY=0 npm install && npm test",
107+
"test:benchmark": "cd examples/benchmark && npm test",
107108
"test:browser": "wdio run ./wdio.conf.js",
108-
"test:node": "npm-run-all --parallel examples:node:**",
109-
"test:pack": "./scripts/testpack.sh",
109+
"test:node": "npm-run-all examples:node:**",
110110
"test:watch": "node --test --enable-source-maps --watch dist/esm/test/*.js",
111111
"test": "node --test --enable-source-maps dist/esm/test/*.js"
112112
},

scripts/build.sh

+22-19
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,29 @@ DIST_DIR="$ROOT/dist"
2020
rm -rf "$DIST_DIR"
2121
mkdir -p "$DIST_DIR"
2222

23-
# Prep build products dir (where we stick npm tarballs)
24-
BUILD_DIR="$ROOT/.build"
25-
rm -rf "$BUILD_DIR"
26-
mkdir -p "$BUILD_DIR"
27-
2823
# Build each module type
2924
for MODULE_TYPE in esm cjs; do
3025
echo "Building ${MODULE_TYPE}"
3126

32-
MODULE_DIST_DIR="$DIST_DIR/${MODULE_TYPE}"
33-
BROWSER_DIR="$DIST_DIR/${MODULE_TYPE}-browser"
27+
NODE_DIST_DIR="$DIST_DIR/${MODULE_TYPE}"
28+
BROWSER_DIST_DIR="$DIST_DIR/${MODULE_TYPE}-browser"
3429

3530
tsc -p tsconfig.${MODULE_TYPE}.json
3631

3732
# Clone files for browser builds
38-
cp -pr ${MODULE_DIST_DIR} ${BROWSER_DIR}
33+
cp -pr ${NODE_DIST_DIR} ${BROWSER_DIST_DIR}
3934

4035
# Remove browser files from non-browser builds
41-
for FILE in ${MODULE_DIST_DIR}/*-browser*;do
36+
for FILE in ${NODE_DIST_DIR}/*-browser*;do
4237
rm -f $FILE
4338
done
4439

4540
# Move browser files into place for browser builds
4641
(
47-
# Temporarily cd into BROWSER_DIR to avoid having to deal with "-browser"
48-
# appearing in both the dir name and file name of FILE's full path
49-
cd ${BROWSER_DIR}
42+
# Temporarily cd into BROWSER_DIST_DIR to avoid having to deal with
43+
# "-browser" appearing in both the dir name and file name of FILE's full
44+
# path
45+
cd ${BROWSER_DIST_DIR}
5046

5147
for FILE in *-browser*;do
5248
mv $FILE ${FILE/-browser/}
@@ -56,17 +52,24 @@ for MODULE_TYPE in esm cjs; do
5652
# esm/cjs-specific logic
5753
if [ "$MODULE_TYPE" = "esm" ]; then
5854
# ESM: copy bin files to dist
59-
cp -pr "$DIST_DIR/../src/bin" "$MODULE_DIST_DIR"
55+
cp -pr "$DIST_DIR/../src/bin" "$NODE_DIST_DIR"
6056
else
6157
# CJS: Add package.json that specifies type: commonjs
62-
echo "{\"type\":\"commonjs\"}" > "$MODULE_DIST_DIR/package.json"
63-
echo "{\"type\":\"commonjs\"}" > "$BROWSER_DIR/package.json"
58+
echo "{\"type\":\"commonjs\"}" > "$NODE_DIST_DIR/package.json"
59+
echo "{\"type\":\"commonjs\"}" > "$BROWSER_DIST_DIR/package.json"
6460
fi
6561
done
6662

67-
# Create tarball for local installation (in tests and examples)
68-
echo "Packing tarball"
69-
npm pack --ignore-scripts --pack-destination "$BUILD_DIR" > /dev/null 2>&1
70-
mv $BUILD_DIR/*.tgz $BUILD_DIR/uuid.tgz
63+
if [ "${1-}" != "--no-pack" ]; then
64+
# Prep tarball dir
65+
BUILD_DIR="$ROOT/.build"
66+
mkdir -p "$BUILD_DIR"
67+
rm -rf "$BUILD_DIR/uuid-*.tgz"
68+
69+
# Create tarball for local installation (in tests and examples)
70+
echo "Packing tarball"
71+
npm pack --pack-destination "$BUILD_DIR" > /dev/null 2>&1
72+
mv $BUILD_DIR/uuid-*.tgz $BUILD_DIR/uuid.tgz
73+
fi
7174

7275
echo "-- fin --"

scripts/testpack.sh

-33
This file was deleted.

0 commit comments

Comments
 (0)