You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

coverage

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coverage - npm Package Compare versions

Comparing version

to
0.1.2

patch.txt

54

index.js
#!/usr/bin/env node
'use strict';
const {createWriteStream, mkdir} = require('fs');
const {dirname, join, resolve: resolvePath} = require('path');
const {mkdir, writeFile} = require('fs');
const {promisify} = require('util');
const {execFile, spawn} = require('child_process');
const {spawn} = require('child_process');

@@ -26,6 +26,6 @@ const foregroundChild = require('foreground-child');

const {_: [command], reporter} = yargsParser(optionArgs);
const promisifiedExecFile = promisify(execFile);
const promisifiedWhich = promisify(which);
const timeout = 2 ** 32 / 2 - 1;
const willUploadLcov = /^1|true$/ui.test(process.env.CI) || !!process.env.GITHUB_ACTION;
const isTravisCi = process.env.TRAVIS === 'true';
// On Windows, write codecov-bash to a file instead of memory to avoid ENAMETOOLONG error

@@ -35,2 +35,18 @@ const codecovBashPath = process.platform === 'win32' ? join(cwd, 'coverage', uuidV4()) : null;

(async () => {
// Remove this workaround when https://github.com/istanbuljs/v8-to-istanbul/pull/16 is merged
if (process.platform === 'win32') {
try {
const patchPath = require.resolve('./patch.txt');
const {readFile, unlink, writeFile} = require('fs');
const originalScriptPath = require.resolve('v8-to-istanbul/lib/script');
const originalScript = await promisify(readFile)(originalScriptPath, 'utf8');
await promisify(writeFile)(originalScriptPath, originalScript.replace(
/_buildLines \(source, lines, shebangLength\) \{[^9]*(?=applyCoverage)/um,
await promisify(readFile)(patchPath, 'utf8')
));
await promisify(unlink)(patchPath);
} catch {}
}
if (command === undefined) {

@@ -107,8 +123,5 @@ require(c8BinPath);

try {
// The default shell of Windows build on Travis CI is Git BASH
if (!(process.platform === 'win32' && process.env.TRAVIS)) {
await Promise.all([
promisifiedExecFile('bash', ['--version'], {timeout}),
promisifiedExecFile('git', ['--version'], {timeout})
]);
// The default shell of Travis CI Windows build is Git BASH
if (!(process.platform === 'win32' && isTravisCi)) {
await Promise.all([promisifiedWhich('bash'), promisifiedWhich('git')]);
}

@@ -142,3 +155,3 @@ } catch {

timeout
}).once('exit', () => resolve('')));
}).once('exit', () => resolve(null)));
}

@@ -156,5 +169,9 @@

if (codecovBashPath) {
await promisify(mkdir)(dirname(codecovBashPath), {recursive: true});
}
await promisify(pipeline)([
request,
new Writable({
codecovBashPath ? createWriteStream(codecovBashPath) : new Writable({
write(chunk, _, cb) {

@@ -167,7 +184,2 @@ body += chunk;

if (codecovBashPath) {
await promisify(mkdir)(dirname(codecovBashPath), {recursive: true});
await promisify(writeFile)(codecovBashPath, body);
}
return body;

@@ -181,4 +193,2 @@ })()

const isTravisCi = process.env.TRAVIS === 'true';
if (isTravisCi) {

@@ -188,10 +198,6 @@ console.log('travis_fold:start:codecov\nupload coverage to codecov.io');

const reportArgs = codecovBash ? [
const reportArgs = codecovBash !== null ? [
'bash',
[
...codecovBashPath ? [codecovBashPath] : [
'-c',
codecovBash,
'--'
],
...codecovBashPath ? [codecovBashPath] : ['-c', codecovBash, '--'],
'-X',

@@ -198,0 +204,0 @@ 'gcov',

{
"name": "coverage",
"version": "0.1.2-1",
"version": "0.1.2",
"description": "A command-line tool to collect and report code coverage of a JavaScript program",

@@ -14,3 +14,3 @@ "author": "Shinnosuke Watanabe (https://github.com/shinnn)",

"index.js",
"nycrc.json"
"patch.txt"
],

@@ -46,3 +46,3 @@ "bin": {

"devDependencies": {
"@shinnn/eslint-config": "^6.10.1",
"@shinnn/eslint-config": "^6.10.2",
"eslint": "^5.16.0",

@@ -49,0 +49,0 @@ "lodash": "^4.17.11",