Repository: codecov/uploader
Pull request #663 (2022-03-14 15:12:41)

Release 0.1.19
#658 


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e4d25a1..caaf371 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
 
 All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
 
+### [0.1.19](https://github.com/codecov/uploader/compare/v0.1.18...v0.1.19) (2022-03-10)
+
+### Bug Fixes
+
+- add helper arg array method, pass in extra gcov args ([57459e3](https://github.com/codecov/uploader/commit/57459e3b98ea9855da67f7d3c9ac6cd2a8e1c398))
+
 ### [0.1.18](https://github.com/codecov/uploader/compare/v0.1.17...v0.1.18) (2022-03-09)
 
 ### Bug Fixes
diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json
index 8e709bc..7c7807c 100644
--- a/npm-shrinkwrap.json
+++ b/npm-shrinkwrap.json
@@ -1,12 +1,12 @@
 {
   "name": "@codecov/uploader",
-  "version": "0.1.18",
+  "version": "0.1.19",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "@codecov/uploader",
-      "version": "0.1.18",
+      "version": "0.1.19",
       "license": "ISC",
       "dependencies": {
         "fast-glob": "3.2.11",
diff --git a/package.json b/package.json
index c41c3e7..4077853 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@codecov/uploader",
-  "version": "0.1.18",
+  "version": "0.1.19",
   "description": "Codecov Report Uploader",
   "private": true,
   "bin": {
diff --git a/src/helpers/gcov.ts b/src/helpers/gcov.ts
index dd449e1..91cda05 100644
--- a/src/helpers/gcov.ts
+++ b/src/helpers/gcov.ts
@@ -3,7 +3,7 @@ import glob from 'fast-glob'
 import { manualBlocklist } from '../../src/helpers/files'
 import { isProgramInstalled, runExternalProgram } from "./util"
 
-export async function generateGcovCoverageFiles(projectRoot: string, include: string[] = [], ignore: string[] = [], gcovArgs = '',): Promise<string> {
+export async function generateGcovCoverageFiles(projectRoot: string, include: string[] = [], ignore: string[] = [], gcovArgs: string[] = []): Promise<string> {
     if (!isProgramInstalled('gcov')) {
         throw new Error('gcov is not installed, cannot process files')
     }
@@ -15,5 +15,5 @@ export async function generateGcovCoverageFiles(projectRoot: string, include: st
     if (!files.length) {
         throw new Error('No gcov files found')
     }
-    return runExternalProgram('gcov', ['-pb', gcovArgs, ...files]);
+    return runExternalProgram('gcov', ['-pb', ...gcovArgs, ...files]);
 }
diff --git a/src/helpers/util.ts b/src/helpers/util.ts
index f5d172f..0e9919b 100644
--- a/src/helpers/util.ts
+++ b/src/helpers/util.ts
@@ -18,3 +18,11 @@ export function runExternalProgram(
 export function isSetAndNotEmpty(val: string | undefined): boolean {
   return typeof val !== 'undefined' && val !== ''
 }
+
+export function argAsArray<T>(args?: T | T[]): T[] {
+  const result: T[] = []
+  if (typeof args === "undefined") {
+    return result
+  }
+  return result.concat(args)
+}
diff --git a/src/index.ts b/src/index.ts
index dd03d45..050dbab 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -23,6 +23,7 @@ import {
   removeFile,
 } from './helpers/files'
 import { generateGcovCoverageFiles } from './helpers/gcov'
+import { argAsArray } from './helpers/util'
 
 /**
  *
@@ -158,18 +159,15 @@ export async function main(
 
   if (args.gcov) {
     UploadLogger.verbose('Running gcov...')
-    const gcovLogs = await generateGcovCoverageFiles(projectRoot)
+    const gcovInclude: string[] = argAsArray(args.gcovInclude)
+    const gcovIgnore: string[] = argAsArray(args.gcovIgnore)
+    const gcovArgs: string[] = argAsArray(args.gcovArgs)
+    const gcovLogs = await generateGcovCoverageFiles(projectRoot, gcovInclude, gcovIgnore, gcovArgs)
     UploadLogger.verbose(`${gcovLogs}`)
   }
   
   let coverageFilePaths: string[] = []
-  if (args.file) {
-    if (typeof args.file === 'string') {
-      requestedPaths = [args.file]
-    } else {
-      requestedPaths = args.file
-    }
-  }
+  requestedPaths = argAsArray(args.file)
 
   coverageFilePaths = requestedPaths
 
diff --git a/src/types.ts b/src/types.ts
index 84c6507..90799e5 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -27,9 +27,9 @@ export interface UploaderArgs {
   source?: string // Track wrappers of the uploader
   changelog?: string // Displays the changelog and exits
   gcov?: string // Run with gcov support
-  gcovIgnore?: string // Paths to ignore during gcov gathering
-  gcovInclude?: string // Paths to include during gcov gathering
-  gcovArgs?: string // Extra arguments to pass to gcov
+  gcovIgnore?:  string | string[] // Paths to ignore during gcov gathering
+  gcovInclude?:  string | string[] // Paths to include during gcov gathering
+  gcovArgs?:  string | string[] // Extra arguments to pass to gcov
 }
 
 export type UploaderEnvs = NodeJS.Dict<string>


Test patch:
diff --git a/test/helpers/gcov.test.ts b/test/helpers/gcov.test.ts
index b2c0c20..23ce823 100644
--- a/test/helpers/gcov.test.ts
+++ b/test/helpers/gcov.test.ts
@@ -34,7 +34,7 @@ describe('generateGcovCoverageFiles()', () => {
         })
 
         const projectRoot = process.cwd()
-        expect(await generateGcovCoverageFiles(projectRoot, [], [], 'NEWGCOVARG')).toEqual("Matched")
+        expect(await generateGcovCoverageFiles(projectRoot, [], [], ['NEWGCOVARG'])).toEqual("Matched")
     })
 
     it('should return an error when no gcno files found', async () => {
@@ -57,6 +57,6 @@ describe('generateGcovCoverageFiles()', () => {
         td.when(spawnSync('gcov')).thenReturn({ error: "Command 'gcov' not found" })
 
         const projectRoot = process.cwd()
-        await expect(generateGcovCoverageFiles(projectRoot, [], [], 'NEWGCOVARG')).rejects.toThrowError(/gcov is not installed/)
+        await expect(generateGcovCoverageFiles(projectRoot, [], [], ['NEWGCOVARG'])).rejects.toThrowError(/gcov is not installed/)
     })
 })