Skip to content

Commit 1c0963b

Browse files
committed
Update tooling
1 parent f83a1d8 commit 1c0963b

8 files changed

Lines changed: 57 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ jobs:
2525
- run: npm run dist
2626
- run: npm run lint
2727
- run: npm test
28+
- run: npm run verify:publish

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
22
dist
3+
test/verify-publish/node_modules
4+
test/verify-publish/package-lock.json
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "parth",
3-
"type": "module",
43
"main": "dist/index.js",
54
"version": "4.2.3",
65
"engines": "{\"node\":\">= 14\"}",
@@ -15,7 +14,8 @@
1514
"lint": "eslint src test example.ts --fix",
1615
"test": "jest",
1716
"dist": "tsc",
18-
"prepublishOnly": "npm run dist"
17+
"prepublishOnly": "npm run dist",
18+
"verify:publish": "bash test/verify-publish/test.sh"
1919
},
2020
"devDependencies": {
2121
"@types/jest": "30.0.0",

test/verify-publish/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "parth-verify",
3+
"private": true,
4+
"type": "module",
5+
"dependencies": {
6+
"parth": "file:../../parth-4.2.3.tgz"
7+
}
8+
}

test/verify-publish/smoke-test.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pkg from 'parth';
2+
const Parth = pkg.default ?? pkg;
3+
4+
const p = new Parth();
5+
6+
// Basic set/get
7+
p.set('(get|post) /:page/:view');
8+
const result = p.get('get /weekend/baby?query=string#hash');
9+
if (!result) throw new Error('Expected match');
10+
if (result.params?.page !== 'weekend') throw new Error('Expected params.page');
11+
if (result.params?.view !== 'baby') throw new Error('Expected params.view');
12+
if (!result.params?.qs?.includes('query=string')) throw new Error('Expected params.qs');
13+
14+
// Options
15+
const p2 = new Parth({ defaultRE: /\S+/ });
16+
p2.set('do :src :dest');
17+
const r2 = p2.get('do /src/**/*.js /dest/');
18+
if (!r2) throw new Error('Expected match with custom defaultRE');
19+
20+
console.log('Smoke test passed');

test/verify-publish/test.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
cd "$(dirname "$0")/../.."
4+
5+
echo "Building..."
6+
npm run dist
7+
8+
echo "Packing..."
9+
npm pack
10+
TARBALL="parth-$(node -p "require('./package.json').version").tgz"
11+
12+
echo "Installing in test/verify-publish..."
13+
cd test/verify-publish
14+
npm install "../../${TARBALL}"
15+
cd ../..
16+
17+
echo "Running smoke test..."
18+
node test/verify-publish/smoke-test.mjs
19+
20+
echo "Cleaning up..."
21+
rm -f "${TARBALL}"
22+
rm -rf test/verify-publish/node_modules test/verify-publish/package-lock.json
23+
24+
echo "verify:publish passed"

0 commit comments

Comments
 (0)