Skip to content

Commit 4099457

Browse files
Make the package buildable and testable
1 parent 7834913 commit 4099457

7 files changed

+54
-15
lines changed

package.cjs.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"name": "@cucumber/message-streams",
23
"type": "commonjs"
34
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@types/mocha": "9.1.0",
3939
"@types/node": "16.11.26",
4040
"mocha": "9.2.2",
41+
"ts-node": "^10.7.0",
4142
"typescript": "4.6.2"
4243
},
4344
"bugs": {

src/NdjsonToMessageStream.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ export default class NdjsonToMessageStream extends Transform {
2222
}
2323
this.buffer += Buffer.isBuffer(chunk) ? chunk.toString('utf-8') : chunk
2424
const lines = this.buffer.split('\n')
25-
this.buffer = lines.pop()
25+
26+
if (!lines.length) {
27+
callback()
28+
return
29+
}
30+
31+
this.buffer = lines.pop() as string
2632
for (const line of lines) {
2733
if (line.trim().length > 0) {
2834
try {

tsconfig.build-cjs.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
2-
"extends": "../../tsconfig.build-cjs.json",
2+
"extends": "./tsconfig.build.json",
33
"compilerOptions": {
4-
"rootDir": ".",
5-
"outDir": "dist/cjs"
4+
"outDir": "dist/cjs",
5+
"target": "ES5",
6+
"module": "CommonJS",
67
},
7-
"include": [
8-
"src",
9-
"test"
10-
],
118
}

tsconfig.build-esm.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
2-
"extends": "../../tsconfig.build-esm.json",
2+
"extends": "./tsconfig.build.json",
33
"compilerOptions": {
4-
"rootDir": ".",
4+
"target": "ES6",
5+
"module": "ES6",
56
"outDir": "dist/esm"
67
},
7-
"include": [
8-
"src",
9-
"test"
10-
],
118
}

tsconfig.build.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"composite": true,
5+
"declaration": true,
6+
"declarationMap": true,
7+
"sourceMap": true,
8+
"target": "es6",
9+
"module": "commonjs",
10+
"rootDir": ".",
11+
"outDir": "dist",
12+
"noEmit": false
13+
},
14+
"include": [
15+
"src",
16+
"test"
17+
]
18+
}

tsconfig.json

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
{
2-
"extends": "../../tsconfig.esm.json"
2+
"compilerOptions": {
3+
"declaration": true,
4+
"target": "es2018",
5+
"lib": [
6+
"es2019",
7+
],
8+
"sourceMap": true,
9+
"allowJs": false,
10+
"resolveJsonModule": true,
11+
"module": "esNext",
12+
"esModuleInterop": true,
13+
"noImplicitAny": true,
14+
"moduleResolution": "node",
15+
"outDir": "dist",
16+
"downlevelIteration": true,
17+
"skipLibCheck": true,
18+
"strictNullChecks": true,
19+
"experimentalDecorators": true,
20+
"noEmit": true
21+
}
322
}

0 commit comments

Comments
 (0)