diff --git a/.gitignore b/.gitignore index c5726c0..b309e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules npm-debug.log .DS_Store package-lock.json +yarn.lock /.idea .eslintcache /lcov.info diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..fe3ea8c --- /dev/null +++ b/index.d.ts @@ -0,0 +1,14 @@ +import { Transform } from 'node:stream' + +type ConfigurationPojo = { + pattern: string + outFile?: string + prependSourceFiles?: boolean + prependPathFix?: string + legacyTempFile?: boolean + ignore?: string[] +} + +export function mergeCoverageReportFiles(filePaths: string[], options: ConfigurationPojo): Promise + +export function mergeCoverageReportFilesStream(filePathsOrMergeOptions: string[] | ConfigurationPojo, mergeOptions?: ConfigurationPojo): Transform diff --git a/package.json b/package.json index 3c7a460..a3f12db 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,18 @@ "name": "lcov-result-merger", "description": "Merges multiple lcov results into one", "main": "index.js", + "types": "index.d.ts", "files": [ "index.js", + "index.d.ts", "bin", "lib" ], "scripts": { "lint": "eslint . --cache", - "test": "npm run lint && npm run test:js", + "test": "npm run lint && npm run test:js && npm run test:dts", "test:js": "mocha --bail --recursive", + "test:dts": "tsd -f test/test-types/index.test-d.ts", "test:coverage": "nyc --reporter=html --reporter=lcov mocha -- --recursive", "release": "release-it", "cleanup": "rm -rf ./.nyc_output ./coverage ./.eslintcache" @@ -45,6 +48,7 @@ }, "devDependencies": { "@release-it/conventional-changelog": "^6.0.0", + "@types/node": "^20.9.0", "@types/yargs": "^17.0.10", "chai": "^4.1.2", "eslint": "^8.30.0", @@ -57,7 +61,8 @@ "nyc": "^15.1.0", "prettier": "2.8.1", "release-it": "^15.11.0", - "rimraf": "^5.0.1" + "rimraf": "^5.0.1", + "tsd": "^0.29.0" }, "engines": { "node": ">=14" diff --git a/test/test-types/index.test-d.ts b/test/test-types/index.test-d.ts new file mode 100644 index 0000000..03b7240 --- /dev/null +++ b/test/test-types/index.test-d.ts @@ -0,0 +1,10 @@ +import { expectType, expectError } from 'tsd' +import { Transform } from 'node:stream' +import { mergeCoverageReportFilesStream, mergeCoverageReportFiles } from '../../index' + +expectType>(mergeCoverageReportFiles(['a', 'b'], {pattern: 'a'})) +expectType(mergeCoverageReportFilesStream(['a', 'b'], {pattern: 'a'})) +expectType(mergeCoverageReportFilesStream({pattern: 'a'})) + +expectError(mergeCoverageReportFiles(['a', 'b'], {pattern: 1})) +expectError(mergeCoverageReportFiles(['a', 'b']))