Main workflow function that orchestrates the complete coverage submission process from LCOV input to Coveralls.io API submission.
Handles the complete workflow of processing LCOV coverage data and submitting it to Coveralls.io.
/**
* Process LCOV coverage data and submit to Coveralls.io
* @param input - LCOV format coverage data as string
* @param callback - Error-first callback with result
* @param userOptions - Optional user-provided configuration overrides
*/
function handleInput(
input: string,
callback: (err: Error | null, result?: string) => void,
userOptions?: object
): void;Usage Examples:
const coveralls = require('coveralls');
const fs = require('fs');
// Basic usage with LCOV file
const lcovData = fs.readFileSync('./coverage/lcov.info', 'utf8');
coveralls.handleInput(lcovData, (err, result) => {
if (err) {
console.error('Error:', err);
process.exit(1);
}
console.log('Success:', result);
});
// With custom options
const userOptions = {
service_name: 'custom-ci',
repo_token: 'your-repo-token'
};
coveralls.handleInput(lcovData, (err, result) => {
if (err) {
console.error('Coverage submission failed:', err);
} else {
console.log('Coverage submitted successfully');
}
}, userOptions);The handleInput function performs these operations in sequence:
getOptions() to gather configuration from environment variables, CI detection, and user overridesconvertLcovToCoveralls() to parse LCOV data and transform to Coveralls formatsendToCoveralls() to post data to Coveralls.io APIThe function handles errors at each workflow step:
Common error scenarios:
coveralls.handleInput(lcovData, (err, result) => {
if (err) {
if (err.message.includes('Bad response')) {
// API returned error status
console.error('Coveralls API error:', err);
} else if (err.message.includes('error from getOptions')) {
// Configuration problem
console.error('Configuration error:', err);
} else if (err.message.includes('error from convertLcovToCoveralls')) {
// LCOV parsing problem
console.error('LCOV conversion error:', err);
} else {
// Network or other error
console.error('Unexpected error:', err);
}
return;
}
// Success
console.log('Coverage submitted:', result);
});This function is used by the CLI tool to process stdin input:
# Direct piping
cat coverage/lcov.info | coveralls
# With test frameworks
jest --coverage && coveralls < coverage/lcov.info
mocha --reporter mocha-lcov-reporter | coveralls