Skip to content

Commit 42d9370

Browse files
committed
Add script to publish from dist folder
1 parent 225e8ac commit 42d9370

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.tsbuildinfo

package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
"combinators",
1919
"typescript"
2020
],
21-
"main": "dist/lib.js",
22-
"files": [
23-
"dist"
24-
],
21+
"main": "lib.js",
2522
"scripts": {
2623
"start": "ts-node src/lib.ts",
2724
"watch": "ts-node-dev src/lib.ts",
@@ -34,7 +31,7 @@
3431
"rebuild:prod": "npm run clean && npm run build:prod",
3532
"test": "jest --passWithNoTests",
3633
"test:watch": "npm test -- --watch",
37-
"prepublishOnly": "npm run rebuild:prod",
34+
"pub": "npm run rebuild:prod && ts-node scripts/copy-to-dist.ts && cd dist && npm publish",
3835
"docs": "typedoc --options typedoc/config.json src",
3936
"watch:docs": "nodemon -e js,ts,json,md,hbs,css --ignore docs/ --exec \"npm run docs\""
4037
},

scripts/copy-to-dist.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { copyFileSync } from 'fs';
2+
import path from 'path';
3+
4+
const file = (filename: string): [string, string] => [
5+
path.join(__dirname, `../${filename}`),
6+
path.join(__dirname, `../dist/${filename}`),
7+
];
8+
9+
const filesToCopy = ['.npmignore', 'LICENSE', 'package.json', 'README.md'];
10+
for (const filename of filesToCopy) {
11+
copyFileSync(...file(filename));
12+
}

0 commit comments

Comments
 (0)