File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525 - run : npm run dist
2626 - run : npm run lint
2727 - run : npm test
28+ - run : npm run verify:publish
Original file line number Diff line number Diff line change 11node_modules
22dist
3+ test /verify-publish /node_modules
4+ test /verify-publish /package-lock.json
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 11{
22 "name" : " parth" ,
3- "type" : " module" ,
43 "main" : " dist/index.js" ,
54 "version" : " 4.2.3" ,
65 "engines" : " {\" node\" :\" >= 14\" }" ,
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" ,
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " parth-verify" ,
3+ "private" : true ,
4+ "type" : " module" ,
5+ "dependencies" : {
6+ "parth" : " file:../../parth-4.2.3.tgz"
7+ }
8+ }
Original file line number Diff line number Diff line change 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' ) ;
Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments