Comparing version 3.0.7 to 3.0.8
#!/usr/bin/env node | ||
var handleInput = require('../lib/handleInput'); | ||
var logger = require('../lib/logger'); | ||
'use strict'; | ||
const { handleInput } = require('..'); | ||
process.stdin.resume(); | ||
process.stdin.setEncoding('utf8'); | ||
var input = ''; | ||
let input = ''; | ||
process.stdin.on('data', function(chunk) { | ||
input += chunk; | ||
process.stdin.on('data', chunk => { | ||
input += chunk; | ||
}); | ||
process.stdin.on('end', function() { | ||
handleInput(input, function(err) { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
process.stdin.on('end', () => { | ||
handleInput(input, err => { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
}); | ||
29
index.js
@@ -1,16 +0,23 @@ | ||
var minimist = require('minimist'); | ||
'use strict'; | ||
const minimist = require('minimist'); | ||
// this needs to go before the other require()s so that | ||
// the other files can already use index.options | ||
exports.options = minimist(process.argv.slice(2), { | ||
boolean: ['verbose', 'stdout'], | ||
alias: { 'v': 'verbose', 's': 'stdout' } | ||
module.exports.options = minimist(process.argv.slice(2), { | ||
boolean: [ | ||
'verbose', | ||
'stdout' | ||
], | ||
alias: { | ||
'v': 'verbose', | ||
's': 'stdout' | ||
} | ||
}); | ||
var dir = './lib/'; | ||
exports.convertLcovToCoveralls = require(dir + 'convertLcovToCoveralls'); | ||
exports.sendToCoveralls = require(dir + 'sendToCoveralls'); | ||
exports.getBaseOptions = require(dir + 'getOptions').getBaseOptions; | ||
exports.getOptions = require(dir + 'getOptions').getOptions; | ||
exports.handleInput = require(dir + 'handleInput'); | ||
exports.logger = require(dir + 'logger'); | ||
module.exports.convertLcovToCoveralls = require('./lib/convertLcovToCoveralls'); | ||
module.exports.sendToCoveralls = require('./lib/sendToCoveralls'); | ||
module.exports.getBaseOptions = require('./lib/getOptions').getBaseOptions; | ||
module.exports.getOptions = require('./lib/getOptions').getOptions; | ||
module.exports.handleInput = require('./lib/handleInput'); | ||
module.exports.logger = require('./lib/logger'); |
@@ -1,10 +0,12 @@ | ||
var TRAVIS_JOB_ID = process.env.TRAVIS_JOB_ID || 'unknown'; | ||
var fs = require('fs'); | ||
var lcovParse = require('lcov-parse'); | ||
var path = require('path'); | ||
var logger = require('./logger')(); | ||
'use strict'; | ||
var detailsToCoverage = function(length, details){ | ||
var coverage = new Array(length); | ||
details.forEach(function(obj){ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const lcovParse = require('lcov-parse'); | ||
const logger = require('./logger')(); | ||
const coberturaParse = require('cobertura-parse'); | ||
const detailsToCoverage = (length, details) => { | ||
const coverage = new Array(length); | ||
details.forEach(obj => { | ||
coverage[obj.line - 1] = obj.hit; | ||
@@ -15,6 +17,6 @@ }); | ||
var detailsToBranches = function(details){ | ||
var branches = []; | ||
details.forEach(function(obj){ | ||
['line','block','branch','taken'].forEach(function(key){ | ||
const detailsToBranches = details => { | ||
const branches = []; | ||
details.forEach(obj => { | ||
['line', 'block', 'branch', 'taken'].forEach(key => { | ||
branches.push(obj[key] || 0); | ||
@@ -26,20 +28,23 @@ }); | ||
var convertLcovFileObject = function(file, filepath){ | ||
var rootpath = filepath; | ||
const convertLcovFileObject = (file, filepath) => { | ||
const rootpath = filepath; | ||
filepath = path.resolve(rootpath, file.file); | ||
var source = fs.readFileSync(filepath, 'utf8'); | ||
var lines = source.split("\n"); | ||
var coverage = detailsToCoverage(lines.length, file.lines.details); | ||
var branches = detailsToBranches(file.branches.details); | ||
return { name : path.relative(rootpath, path.resolve(rootpath, file.file)).split( path.sep ).join( "/" ), | ||
source : source, | ||
coverage : coverage, | ||
branches : branches }; | ||
const source = fs.readFileSync(filepath, 'utf8'); | ||
const lines = source.split('\n'); | ||
const coverage = detailsToCoverage(lines.length, file.lines.details); | ||
const branches = detailsToBranches(file.branches.details); | ||
return { | ||
name: path.relative(rootpath, path.resolve(rootpath, file.file)).split(path.sep).join('/'), | ||
source, | ||
coverage, | ||
branches | ||
}; | ||
}; | ||
var cleanFilePath = function(file) { | ||
if (file.indexOf('!') > -1) { | ||
var regex = /^(.*!)(.*)$/g; | ||
var matches = regex.exec(file); | ||
return matches[matches.length-1]; | ||
const cleanFilePath = file => { | ||
if (file.includes('!')) { | ||
const regex = /^(.*!)(.*)$/g; | ||
const matches = regex.exec(file); | ||
return matches[matches.length - 1]; | ||
} | ||
@@ -50,42 +55,58 @@ | ||
var convertLcovToCoveralls = function(input, options, cb){ | ||
var filepath = options.filepath || ''; | ||
logger.debug("in: ", filepath); | ||
const convertLcovToCoveralls = (input, options, cb) => { | ||
let filepath = options.filepath || ''; | ||
logger.debug('in: ', filepath); | ||
filepath = path.resolve(process.cwd(), filepath); | ||
lcovParse(input, function(err, parsed){ | ||
if (err){ | ||
logger.error("error from lcovParse: ", err); | ||
logger.error("input: ", input); | ||
const filetype = options.filetype || 'lcov'; | ||
const parser = filetype === 'cobertura' ? coberturaParse.parseContent : lcovParse; | ||
parser(input, (err, parsed) => { | ||
if (err) { | ||
logger.error('error from lcovParse: ', err); | ||
logger.error('input: ', input); | ||
return cb(err); | ||
} | ||
var postJson = { | ||
source_files : [] | ||
const postJson = { | ||
source_files: [] | ||
}; | ||
if (options.git){ | ||
if (options.flag_name) { | ||
postJson.flag_name = options.flag_name; | ||
} | ||
if (options.git) { | ||
postJson.git = options.git; | ||
} | ||
if (options.run_at){ | ||
if (options.run_at) { | ||
postJson.run_at = options.run_at; | ||
} | ||
if (options.service_name){ | ||
if (options.service_name) { | ||
postJson.service_name = options.service_name; | ||
} | ||
if (options.service_job_id){ | ||
if (options.service_job_id) { | ||
postJson.service_job_id = options.service_job_id; | ||
} | ||
if (options.service_pull_request) { | ||
postJson.service_pull_request = options.service_pull_request; | ||
} | ||
if (options.repo_token) { | ||
postJson.repo_token = options.repo_token; | ||
} | ||
if (options.parallel) { | ||
postJson.parallel = options.parallel; | ||
} | ||
if (options.service_pull_request) { | ||
postJson.service_pull_request = options.service_pull_request; | ||
} | ||
parsed.forEach(function(file){ | ||
parsed.forEach(file => { | ||
file.file = cleanFilePath(file.file); | ||
var currentFilePath = path.resolve(filepath, file.file); | ||
const currentFilePath = path.resolve(filepath, file.file); | ||
if (fs.existsSync(currentFilePath)) { | ||
@@ -103,3 +124,2 @@ postJson.source_files.push(convertLcovFileObject(file, filepath)); | ||
{ | ||
@@ -122,3 +142,2 @@ "service_job_id": "1234567890", | ||
example output from lcov parser: | ||
@@ -125,0 +144,0 @@ |
@@ -1,14 +0,18 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
// branch naming only has a few excluded characters, see git-check-ref-format(1) | ||
var REGEX_BRANCH = /^ref: refs\/heads\/([^?*\[\\~^:]+)$/; | ||
const REGEX_BRANCH = /^ref: refs\/heads\/([^?*[\\~^:]+)$/; | ||
module.exports = function detectLocalGit() { | ||
var dir = process.cwd(), gitDir; | ||
function detectLocalGit() { | ||
let dir = process.cwd(); | ||
let gitDir; | ||
while (path.resolve('/') !== dir) { | ||
gitDir = path.join(dir, '.git'); | ||
var existsSync = fs.existsSync || path.existsSync; | ||
if (existsSync(path.join(gitDir, 'HEAD'))) | ||
if (fs.existsSync(path.join(gitDir, 'HEAD'))) { | ||
break; | ||
} | ||
@@ -18,31 +22,38 @@ dir = path.dirname(dir); | ||
if (path.resolve('/') === dir) | ||
if (path.resolve('/') === dir) { | ||
return; | ||
} | ||
var head = fs.readFileSync(path.join(dir, '.git', 'HEAD'), 'utf-8').trim(); | ||
var branch = (head.match(REGEX_BRANCH) || [])[1]; | ||
if (!branch) | ||
const head = fs.readFileSync(path.join(dir, '.git', 'HEAD'), 'utf-8').trim(); | ||
const branch = (head.match(REGEX_BRANCH) || [])[1]; | ||
if (!branch) { | ||
return { git_commit: head }; | ||
} | ||
var commit = _parseCommitHashFromRef(dir, branch); | ||
const commit = _parseCommitHashFromRef(dir, branch); | ||
return { git_commit: commit, git_branch: branch }; | ||
}; | ||
return { | ||
git_commit: commit, | ||
git_branch: branch | ||
}; | ||
} | ||
function _parseCommitHashFromRef(dir, branch) { | ||
var ref = path.join(dir, '.git', 'refs', 'heads', branch); | ||
if (fs.existsSync(ref)) { | ||
return fs.readFileSync(ref, 'utf-8').trim(); | ||
} else { | ||
// ref does not exist; get it from packed-refs | ||
var commit = ''; | ||
var packedRefs = path.join(dir, '.git', 'packed-refs'); | ||
var packedRefsText = fs.readFileSync(packedRefs, 'utf-8'); | ||
packedRefsText.split('\n').forEach(function (line) { | ||
if (line.match('refs/heads/'+branch)) { | ||
commit = line.split(' ')[0]; | ||
} | ||
}); | ||
return commit; | ||
const ref = path.join(dir, '.git', 'refs', 'heads', branch); | ||
if (fs.existsSync(ref)) { | ||
return fs.readFileSync(ref, 'utf-8').trim(); | ||
} | ||
// ref does not exist; get it from packed-refs | ||
let commit = ''; | ||
const packedRefs = path.join(dir, '.git', 'packed-refs'); | ||
const packedRefsText = fs.readFileSync(packedRefs, 'utf-8'); | ||
packedRefsText.split('\n').forEach(line => { | ||
if (line.match(`refs/heads/${branch}`)) { | ||
commit = line.split(' ')[0]; | ||
} | ||
}); | ||
return commit; | ||
} | ||
module.exports = detectLocalGit; |
@@ -1,17 +0,21 @@ | ||
var exec = require('child_process').exec; | ||
var logger = require('./logger')(); | ||
'use strict'; | ||
const { exec } = require('child_process'); | ||
require('./logger')(); | ||
function fetchGitData(git, cb) { | ||
if (!cb){ | ||
throw new Error("fetchGitData requires a callback"); | ||
if (!cb) { | ||
throw new Error('fetchGitData requires a callback'); | ||
} | ||
//-- Malformed/undefined git object | ||
if ('undefined' === typeof git) { | ||
if (typeof git === 'undefined') { | ||
return cb(new Error('No options passed')); | ||
} | ||
if (!git.hasOwnProperty('head')) { | ||
if (!Object.prototype.hasOwnProperty.call(git, 'head')) { | ||
return cb(new Error('You must provide the head')); | ||
} | ||
if (!git.head.hasOwnProperty('id')) { | ||
if (!Object.prototype.hasOwnProperty.call(git.head, 'id')) { | ||
return cb(new Error('You must provide the head.id')); | ||
@@ -21,6 +25,7 @@ } | ||
//-- Set required properties of git if they weren"t provided | ||
if (!git.hasOwnProperty("branch")) { | ||
git.branch = ""; | ||
if (!Object.prototype.hasOwnProperty.call(git, 'branch')) { | ||
git.branch = ''; | ||
} | ||
if (!git.hasOwnProperty("remotes")) { | ||
if (!Object.prototype.hasOwnProperty.call(git, 'remotes')) { | ||
git.remotes = []; | ||
@@ -30,6 +35,7 @@ } | ||
//-- Assert the property types | ||
if ("string" !== typeof git.branch) { | ||
git.branch = ""; | ||
if (typeof git.branch !== 'string') { | ||
git.branch = ''; | ||
} | ||
if (!(git.remotes instanceof Array)) { | ||
if (!(Array.isArray(git.remotes))) { | ||
git.remotes = []; | ||
@@ -39,10 +45,10 @@ } | ||
//-- Use git? | ||
exec("git rev-parse --verify " + git.head.id, function(err, response){ | ||
if (err){ | ||
exec(`git rev-parse --verify ${git.head.id}`, err => { | ||
if (err) { | ||
// git is not available... | ||
git.head.author_name = git.head.author_name || "Unknown Author"; | ||
git.head.author_email = git.head.author_email || ""; | ||
git.head.committer_name = git.head.committer_name || "Unknown Committer"; | ||
git.head.committer_email = git.head.committer_email || ""; | ||
git.head.message = git.head.message || "Unknown Commit Message"; | ||
git.head.author_name = git.head.author_name || 'Unknown Author'; | ||
git.head.author_email = git.head.author_email || ''; | ||
git.head.committer_name = git.head.committer_name || 'Unknown Committer'; | ||
git.head.committer_email = git.head.committer_email || ''; | ||
git.head.message = git.head.message || 'Unknown Commit Message'; | ||
return cb(null, git); | ||
@@ -56,5 +62,6 @@ } | ||
function fetchBranch(git, cb) { | ||
exec("git branch", function(err, branches){ | ||
if (err) | ||
exec('git branch', (err, branches) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
@@ -66,12 +73,13 @@ git.branch = (branches.match(/^\* (\w+)/) || [])[1]; | ||
var REGEX_COMMIT_DETAILS = /\nauthor (.+?) <([^>]*)>.+\ncommitter (.+?) <([^>]*)>.+[\S\s]*?\n\n(.*)/m; | ||
const REGEX_COMMIT_DETAILS = /\nauthor (.+?) <([^>]*)>.+\ncommitter (.+?) <([^>]*)>.+[\S\s]*?\n\n(.*)/m; | ||
function fetchHeadDetails(git, cb) { | ||
exec('git cat-file -p ' + git.head.id, function(err, response) { | ||
if (err) | ||
exec(`git cat-file -p ${git.head.id}`, (err, response) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
var items = response.match(REGEX_COMMIT_DETAILS).slice(1); | ||
var fields = ['author_name', 'author_email', 'committer_name', 'committer_email', 'message']; | ||
fields.forEach(function(field, index) { | ||
const items = response.match(REGEX_COMMIT_DETAILS).slice(1); | ||
const fields = ['author_name', 'author_email', 'committer_name', 'committer_email', 'message']; | ||
fields.forEach((field, index) => { | ||
git.head[field] = items[index]; | ||
@@ -89,10 +97,13 @@ }); | ||
function fetchRemotes(git, cb) { | ||
exec("git remote -v", function(err, remotes){ | ||
if (err) | ||
exec('git remote -v', (err, remotes) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
var processed = {}; | ||
remotes.split("\n").forEach(function(remote) { | ||
if (!/\s\(push\)$/.test(remote)) | ||
const processed = {}; | ||
remotes.split('\n').forEach(remote => { | ||
if (!/\s\(push\)$/.test(remote)) { | ||
return; | ||
} | ||
remote = remote.split(/\s+/); | ||
@@ -106,10 +117,11 @@ saveRemote(processed, git, remote[0], remote[1]); | ||
function saveRemote(processed, git, name, url) { | ||
var key = name + "-" + url; | ||
if (processed.hasOwnProperty(key)) | ||
const key = `${name}-${url}`; | ||
if (Object.prototype.hasOwnProperty.call(processed, key)) { | ||
return; | ||
} | ||
processed[key] = true; | ||
git.remotes.push({ name: name, url: url }); | ||
git.remotes.push({ name, url }); | ||
} | ||
module.exports = fetchGitData; |
@@ -1,16 +0,21 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var yaml = require('js-yaml'); | ||
var index = require('../index'); | ||
var logger = require('./logger')(); | ||
var fetchGitData = require('./fetchGitData'); | ||
'use strict'; | ||
var getBaseOptions = function(cb){ | ||
var options = {}; | ||
var git_commit = process.env.COVERALLS_GIT_COMMIT; | ||
var git_branch = process.env.COVERALLS_GIT_BRANCH; | ||
var git_committer_name, git_committer_email, git_message; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const yaml = require('js-yaml'); | ||
const logger = require('./logger')(); | ||
const fetchGitData = require('./fetchGitData'); | ||
const detectLocalGit = require('./detectLocalGit'); | ||
const index = require('..'); | ||
var match = (process.env.CI_PULL_REQUEST || "").match(/(\d+)$/); | ||
const getBaseOptions = cb => { | ||
const options = {}; | ||
let git_commit = process.env.COVERALLS_GIT_COMMIT; | ||
let git_branch = process.env.COVERALLS_GIT_BRANCH; | ||
let git_committer_name; | ||
let git_committer_email; | ||
let git_message; | ||
const match = (process.env.CI_PULL_REQUEST || '').match(/(\d+)$/); | ||
if (match) { | ||
@@ -20,3 +25,3 @@ options.service_pull_request = match[1]; | ||
if (process.env.TRAVIS){ | ||
if (process.env.TRAVIS) { | ||
options.service_name = 'travis-ci'; | ||
@@ -29,3 +34,3 @@ options.service_job_id = process.env.TRAVIS_JOB_ID; | ||
if (process.env.DRONE){ | ||
if (process.env.DRONE) { | ||
options.service_name = 'drone'; | ||
@@ -41,3 +46,3 @@ options.service_job_id = process.env.DRONE_BUILD_NUMBER; | ||
if (process.env.JENKINS_URL || process.env.JENKINS_HOME){ | ||
if (process.env.JENKINS_URL || process.env.JENKINS_HOME) { | ||
options.service_name = 'jenkins'; | ||
@@ -52,3 +57,3 @@ options.service_job_id = process.env.BUILD_ID; | ||
if (process.env.CIRCLECI){ | ||
if (process.env.CIRCLECI) { | ||
options.service_name = 'circleci'; | ||
@@ -58,5 +63,6 @@ options.service_job_id = process.env.CIRCLE_BUILD_NUM; | ||
if (process.env.CI_PULL_REQUEST) { | ||
var pr = process.env.CI_PULL_REQUEST.split('/pull/'); | ||
const pr = process.env.CI_PULL_REQUEST.split('/pull/'); | ||
options.service_pull_request = pr[1]; | ||
} | ||
git_commit = process.env.CIRCLE_SHA1; | ||
@@ -66,3 +72,3 @@ git_branch = process.env.CIRCLE_BRANCH; | ||
if (process.env.CI_NAME && process.env.CI_NAME === 'codeship'){ | ||
if (process.env.CI_NAME && process.env.CI_NAME === 'codeship') { | ||
options.service_name = 'codeship'; | ||
@@ -77,3 +83,3 @@ options.service_job_id = process.env.CI_BUILD_NUMBER; | ||
if (process.env.WERCKER){ | ||
if (process.env.WERCKER) { | ||
options.service_name = 'wercker'; | ||
@@ -85,3 +91,3 @@ options.service_job_id = process.env.WERCKER_BUILD_ID; | ||
if (process.env.GITLAB_CI){ | ||
if (process.env.GITLAB_CI) { | ||
options.service_name = 'gitlab-ci'; | ||
@@ -94,3 +100,4 @@ options.service_job_number = process.env.CI_BUILD_NAME; | ||
} | ||
if(process.env.APPVEYOR){ | ||
if (process.env.APPVEYOR) { | ||
options.service_name = 'appveyor'; | ||
@@ -102,3 +109,4 @@ options.service_job_number = process.env.APPVEYOR_BUILD_NUMBER; | ||
} | ||
if(process.env.SURF_SHA1){ | ||
if (process.env.SURF_SHA1) { | ||
options.service_name = 'surf'; | ||
@@ -109,3 +117,3 @@ git_commit = process.env.SURF_SHA1; | ||
if(process.env.BUILDKITE){ | ||
if (process.env.BUILDKITE) { | ||
options.service_name = 'buildkite'; | ||
@@ -122,3 +130,3 @@ options.service_job_number = process.env.BUILDKITE_BUILD_NUMBER; | ||
if(process.env.SEMAPHORE){ | ||
if (process.env.SEMAPHORE) { | ||
options.service_name = 'semaphore'; | ||
@@ -130,3 +138,3 @@ options.service_job_id = process.env.SEMAPHORE_BUILD_NUMBER; | ||
if(process.env.TF_BUILD){ | ||
if (process.env.TF_BUILD) { | ||
options.service_name = 'Azure Pipelines'; | ||
@@ -140,6 +148,7 @@ options.service_job_id = process.env.BUILD_BUILDID; | ||
options.run_at = process.env.COVERALLS_RUN_AT || JSON.stringify(new Date()).slice(1, -1); | ||
if (process.env.COVERALLS_SERVICE_NAME){ | ||
if (process.env.COVERALLS_SERVICE_NAME) { | ||
options.service_name = process.env.COVERALLS_SERVICE_NAME; | ||
} | ||
if (process.env.COVERALLS_SERVICE_JOB_ID){ | ||
if (process.env.COVERALLS_SERVICE_JOB_ID) { | ||
options.service_job_id = process.env.COVERALLS_SERVICE_JOB_ID; | ||
@@ -149,3 +158,3 @@ } | ||
if (!git_commit || !git_branch) { | ||
var data = require('./detectLocalGit')(); | ||
const data = detectLocalGit(); | ||
if (data) { | ||
@@ -166,14 +175,14 @@ git_commit = git_commit || data.git_commit; | ||
// try to get the repo token from a .coveralls.yml file | ||
var yml = path.join(process.cwd(), '.coveralls.yml'); | ||
const yml = path.join(process.cwd(), '.coveralls.yml'); | ||
try { | ||
if (fs.statSync(yml).isFile()) { | ||
var coveralls_yaml_conf = yaml.safeLoad(fs.readFileSync(yml, 'utf8')); | ||
const coveralls_yaml_conf = yaml.safeLoad(fs.readFileSync(yml, 'utf8')); | ||
options.repo_token = coveralls_yaml_conf.repo_token; | ||
if(coveralls_yaml_conf.service_name) { | ||
if (coveralls_yaml_conf.service_name) { | ||
options.service_name = coveralls_yaml_conf.service_name; | ||
} | ||
} | ||
} catch(ex){ | ||
logger.warn("Repo token could not be determined. Continuing without it." + | ||
"This is necessary for private repos only, so may not be an issue at all."); | ||
} catch (_) { | ||
logger.warn('Repo token could not be determined. Continuing without it. ' + | ||
'This is necessary for private repos only, so may not be an issue at all.'); | ||
} | ||
@@ -186,3 +195,3 @@ } | ||
if (git_commit){ | ||
if (git_commit) { | ||
fetchGitData({ | ||
@@ -196,4 +205,4 @@ head: { | ||
branch: git_branch | ||
}, function(err, git){ | ||
if (err){ | ||
}, (err, git) => { | ||
if (err) { | ||
logger.warn('there was an error getting git data: ', err); | ||
@@ -203,2 +212,3 @@ } else { | ||
} | ||
return cb(err, options); | ||
@@ -211,20 +221,24 @@ }); | ||
var getOptions = function(cb, _userOptions){ | ||
if (!cb){ | ||
const getOptions = (cb, _userOptions) => { | ||
if (!cb) { | ||
throw new Error('getOptions requires a callback'); | ||
} | ||
var userOptions = _userOptions || {}; | ||
const userOptions = _userOptions || {}; | ||
getBaseOptions(function(err, options){ | ||
getBaseOptions((err, options) => { | ||
// minimist populates options._ with non-option command line arguments | ||
var firstNonOptionArgument = index.options._[0]; | ||
const firstNonOptionArgument = index.options._[0]; | ||
if (firstNonOptionArgument) | ||
if (firstNonOptionArgument) { | ||
options.filepath = firstNonOptionArgument; | ||
} | ||
// lodash or else would be better, but no need for the extra dependency | ||
for (var option in userOptions) { | ||
options[option] = userOptions[option]; | ||
for (const option in userOptions) { | ||
if (Object.prototype.hasOwnProperty.call(userOptions, option)) { | ||
options[option] = userOptions[option]; | ||
} | ||
} | ||
cb(err, options); | ||
@@ -231,0 +245,0 @@ }); |
@@ -1,31 +0,37 @@ | ||
var index = require('../index'); | ||
var logger = require('./logger')(); | ||
'use strict'; | ||
const logger = require('./logger')(); | ||
const index = require('..'); | ||
function handleInput(input, cb, userOptions) { | ||
logger.debug(input); | ||
logger.debug('user options ' + userOptions); | ||
index.getOptions(function(err, options){ | ||
if (err){ | ||
logger.error("error from getOptions"); | ||
logger.debug(`user options ${userOptions}`); | ||
index.getOptions((err, options) => { | ||
if (err) { | ||
logger.error('error from getOptions'); | ||
cb(err); | ||
return; | ||
} | ||
logger.debug(options); | ||
index.convertLcovToCoveralls(input, options, function(err, postData){ | ||
if (err){ | ||
logger.error("error from convertLcovToCoveralls"); | ||
index.convertLcovToCoveralls(input, options, (err, postData) => { | ||
if (err) { | ||
logger.error('error from convertLcovToCoveralls'); | ||
cb(err); | ||
return; | ||
} | ||
logger.info("sending this to coveralls.io: ", JSON.stringify(postData)); | ||
index.sendToCoveralls(postData, function(err, response, body){ | ||
if (err){ | ||
logger.info('sending this to coveralls.io: ', JSON.stringify(postData)); | ||
index.sendToCoveralls(postData, (err, response, body) => { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
if (response.statusCode >= 400){ | ||
cb("Bad response: " + response.statusCode + " " + body); | ||
if (response.statusCode >= 400) { | ||
cb(`Bad response: ${response.statusCode} ${body}`); | ||
return; | ||
} | ||
logger.debug(response.statusCode); | ||
@@ -32,0 +38,0 @@ logger.debug(body); |
@@ -1,16 +0,14 @@ | ||
var index = require('../index'); | ||
'use strict'; | ||
module.exports = function(){ | ||
return require('log-driver')({level : getLogLevel()}); | ||
}; | ||
const logDriver = require('log-driver'); | ||
const index = require('..'); | ||
function getLogLevel(){ | ||
if (index.options.verbose || hasDebugEnvVariable()) { | ||
module.exports = () => logDriver({ level: getLogLevel() }); | ||
function getLogLevel() { | ||
if (index.options.verbose || Boolean(process.env.NODE_COVERALLS_DEBUG)) { | ||
return 'debug'; | ||
} | ||
return 'error'; | ||
} | ||
function hasDebugEnvVariable(){ | ||
return process.env.NODE_COVERALLS_DEBUG == 1; | ||
} |
@@ -1,6 +0,8 @@ | ||
var request = require('request'); | ||
var index = require('../index'); | ||
'use strict'; | ||
var sendToCoveralls = function(obj, cb){ | ||
var urlBase = 'https://coveralls.io'; | ||
const request = require('request'); | ||
const index = require('..'); | ||
const sendToCoveralls = (obj, cb) => { | ||
let urlBase = 'https://coveralls.io'; | ||
if (process.env.COVERALLS_ENDPOINT) { | ||
@@ -10,5 +12,5 @@ urlBase = process.env.COVERALLS_ENDPOINT; | ||
var str = JSON.stringify(obj); | ||
var url = urlBase + '/api/v1/jobs'; | ||
const str = JSON.stringify(obj); | ||
const url = `${urlBase}/api/v1/jobs`; | ||
if (index.options.stdout) { | ||
@@ -18,3 +20,8 @@ process.stdout.write(str); | ||
} else { | ||
request.post({url : url, form : { json : str}}, function(err, response, body){ | ||
request.post({ | ||
url, | ||
form: { | ||
json: str | ||
} | ||
}, (err, response, body) => { | ||
cb(err, response, body); | ||
@@ -21,0 +28,0 @@ }); |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "3.0.7", | ||
"version": "3.0.8", | ||
"bugs": { | ||
@@ -14,3 +14,9 @@ "url": "https://github.com/nickmerwin/node-coveralls/issues" | ||
"scripts": { | ||
"test": "snyk test && make test" | ||
"lint": "jshint ./lib ./test ./index.js", | ||
"mocha": "_mocha -b -R spec", | ||
"test-cov": "nyc npm run mocha", | ||
"pretest-coveralls": "npm run pretest", | ||
"test-coveralls": "nyc npm run mocha && shx cat ./coverage/lcov.info | node ./bin/coveralls.js --verbose", | ||
"pretest": "cross-env-shell \"echo TRAVIS_JOB_ID $TRAVIS_JOB_ID\"", | ||
"test": "snyk test && npm run lint && npm run mocha" | ||
}, | ||
@@ -35,20 +41,23 @@ "bin": { | ||
"dependencies": { | ||
"growl": "~> 1.10.0", | ||
"cobertura-parse": "^1.0.5", | ||
"js-yaml": "^3.13.1", | ||
"lcov-parse": "^0.0.10", | ||
"lcov-parse": "^1.0.0", | ||
"log-driver": "^1.2.7", | ||
"minimist": "^1.2.0", | ||
"request": "^2.86.0" | ||
"request": "^2.88.0" | ||
}, | ||
"devDependencies": { | ||
"cross-env": "^5.2.1", | ||
"nyc": "^14.1.1", | ||
"istanbul": "^0.4.5", | ||
"jshint": "^2.10.1", | ||
"mocha": "^6.1.4", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"jshint": "^2.10.3", | ||
"mocha": "^6.2.2", | ||
"mocha-lcov-reporter": "^1.3.0", | ||
"should": "^9.0.2", | ||
"shx": "^0.3.2", | ||
"sinon-restore": "^1.0.1", | ||
"snyk": "^1.134.2" | ||
"snyk": "^1.250.0" | ||
}, | ||
"engines": { | ||
"node": ">=4.0.0" | ||
"node": ">=6" | ||
}, | ||
@@ -64,3 +73,13 @@ "main": "index.js", | ||
"author": "Gregg Caines", | ||
"license": "BSD-2-Clause" | ||
"license": "BSD-2-Clause", | ||
"nyc": { | ||
"reporter": [ | ||
"lcov", | ||
"text-summary" | ||
] | ||
}, | ||
"files": [ | ||
"{bin,lib}/*.js", | ||
"index.js" | ||
] | ||
} |
# node-coveralls | ||
[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] | ||
[![Build Status][ci-image]][ci-url] [![Coverage Status][coveralls-image]][coveralls-url] | ||
[![Known Vulnerabilities](https://snyk.io/test/github/nickmerwin/node-coveralls/badge.svg)](https://snyk.io/test/github/nickmerwin/node-coveralls) | ||
@@ -150,4 +150,4 @@ | ||
[travis-image]: https://travis-ci.org/nickmerwin/node-coveralls.svg?branch=master | ||
[travis-url]: https://travis-ci.org/nickmerwin/node-coveralls | ||
[ci-image]: https://github.com/nickmerwin/node-coveralls/workflows/Tests/badge.svg | ||
[ci-url]: https://github.com/nickmerwin/node-coveralls/actions?workflow=Tests | ||
@@ -154,0 +154,0 @@ [coveralls-image]: https://coveralls.io/repos/nickmerwin/node-coveralls/badge.svg?branch=master&service=github |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
92
30286
10
12
586
2
+ Addedcobertura-parse@^1.0.5
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbrowser-stdout@1.3.1(transitive)
+ Addedcobertura-parse@1.0.5(transitive)
+ Addedcommander@2.11.0(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addeddebug@3.1.0(transitive)
+ Addeddiff@3.5.0(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.1.2(transitive)
+ Addedgrowl@1.10.3(transitive)
+ Addedhas-flag@2.0.0(transitive)
+ Addedhe@1.1.1(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedlcov-parse@1.0.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@0.0.8(transitive)
+ Addedmkdirp@0.5.1(transitive)
+ Addedmocha@5.0.5(transitive)
+ Addedms@2.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsupports-color@4.4.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxml2js@0.4.19(transitive)
+ Addedxmlbuilder@9.0.7(transitive)
- Removedgrowl@~> 1.10.0
- Removedgrowl@1.10.5(transitive)
- Removedlcov-parse@0.0.10(transitive)
Updatedlcov-parse@^1.0.0
Updatedrequest@^2.88.0