Skip to content

Commit

Permalink
Including support for custom filename and process.argv as second choi…
Browse files Browse the repository at this point in the history
…ce at mergeResults
  • Loading branch information
Eduardo-Cardenas-Teracode committed Feb 7, 2020
1 parent 371f12a commit 65037df
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/mergeResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ const fs = require('fs')
const path = require('path')

const mergeResults = (...args) => {
const dir = args[0]
const filePattern = args[1]
const dir = args[0] || process.argv[2]
const filePattern = args[1] || process.argv[3]
const customFileName = args[2] || process.argv[4]

const rawData = getDataFromFiles(dir, filePattern)
const mergedResults = mergeData(rawData)
writeFile(dir, mergedResults)
writeFile(dir, mergedResults, customFileName)
}

function getDataFromFiles (dir, filePattern) {
Expand Down Expand Up @@ -43,8 +44,8 @@ function mergeData (rawData) {
return mergedResults
}

function writeFile (dir, mergedResults) {
const fileName = 'wdio-merged.json'
function writeFile (dir, mergedResults, customFileName) {
let fileName = customFileName || 'wdio-merged.json'
const filePath = path.join(dir, fileName)
fs.writeFileSync(filePath, JSON.stringify(mergedResults))
}
Expand Down

0 comments on commit 65037df

Please sign in to comment.