Comparing version 7.1.2 to 7.2.0-beta.0
@@ -20,5 +20,6 @@ export type Watermark = [number, number]; | ||
all?: boolean, | ||
src?: Array<string>, | ||
allowExternal: boolean | ||
}) | ||
run(): Promise<void>; | ||
} | ||
} |
@@ -23,3 +23,5 @@ const { checkCoverages } = require('./check-coverage') | ||
wrapperLength: argv.wrapperLength, | ||
all: argv.all | ||
all: argv.all, | ||
allowExternal: argv.allowExternal, | ||
src: argv.src | ||
}) | ||
@@ -26,0 +28,0 @@ await report.run() |
@@ -92,2 +92,14 @@ const defaultExclude = require('@istanbuljs/schema/default-exclude') | ||
}) | ||
.options('allowExternal', { | ||
default: false, | ||
type: 'boolean', | ||
describe: 'supplying --allowExternal will cause c8 to allow files from outside of your cwd. This applies both to' + | ||
'files discovered in coverage temp files and also src files discovered if using the --all flag.' | ||
}) | ||
.options('src', { | ||
default: undefined, | ||
type: 'string', | ||
describe: 'supplying --src will override cwd as the default location where --all looks for src files. --src can be ' + | ||
'supplied multiple times and each directory will be included. This allows for workspaces spanning multiple projects' | ||
}) | ||
.pkgConf('c8') | ||
@@ -94,0 +106,0 @@ .config(config) |
@@ -24,3 +24,5 @@ const Exclude = require('test-exclude') | ||
resolve: resolvePaths, | ||
all | ||
all, | ||
src, | ||
allowExternal = false | ||
}) { | ||
@@ -34,3 +36,4 @@ this.reporter = reporter | ||
exclude: exclude, | ||
include: include | ||
include: include, | ||
relativePath: !allowExternal | ||
}) | ||
@@ -41,5 +44,15 @@ this.omitRelative = omitRelative | ||
this.all = all | ||
this.src = process.cwd() | ||
this.src = this._getSrc(src) | ||
} | ||
_getSrc (src) { | ||
if (typeof src === 'string') { | ||
return [src] | ||
} else if (Array.isArray(src)) { | ||
return src | ||
} else { | ||
return [process.cwd()] | ||
} | ||
} | ||
async run () { | ||
@@ -165,29 +178,31 @@ var context = libReport.createContext({ | ||
}) | ||
const workingDir = process.cwd() | ||
this.exclude.globSync(workingDir).forEach((f) => { | ||
const fullPath = resolve(workingDir, f) | ||
if (!fileIndex.has(fullPath)) { | ||
const ext = extname(f) | ||
if (ext === '.js' || ext === '.ts' || ext === '.mjs') { | ||
const stat = statSync(f) | ||
const sourceMap = getSourceMapFromFile(f) | ||
if (sourceMap !== undefined) { | ||
this.sourceMapCache[`file://${fullPath}`] = { data: JSON.parse(readFileSync(sourceMap).toString()) } | ||
const workingDirs = this.src | ||
for (const workingDir of workingDirs) { | ||
this.exclude.globSync(workingDir).forEach((f) => { | ||
const fullPath = resolve(workingDir, f) | ||
if (!fileIndex.has(fullPath)) { | ||
const ext = extname(fullPath) | ||
if (ext === '.js' || ext === '.ts' || ext === '.mjs') { | ||
const stat = statSync(fullPath) | ||
const sourceMap = getSourceMapFromFile(fullPath) | ||
if (sourceMap !== undefined) { | ||
this.sourceMapCache[`file://${fullPath}`] = { data: JSON.parse(readFileSync(sourceMap).toString()) } | ||
} | ||
emptyReports.push({ | ||
scriptId: 0, | ||
url: resolve(fullPath), | ||
functions: [{ | ||
functionName: '(empty-report)', | ||
ranges: [{ | ||
startOffset: 0, | ||
endOffset: stat.size, | ||
count: 0 | ||
}], | ||
isBlockCoverage: true | ||
}] | ||
}) | ||
} | ||
emptyReports.push({ | ||
scriptId: 0, | ||
url: resolve(f), | ||
functions: [{ | ||
functionName: '(empty-report)', | ||
ranges: [{ | ||
startOffset: 0, | ||
endOffset: stat.size, | ||
count: 0 | ||
}], | ||
isBlockCoverage: true | ||
}] | ||
}) | ||
} | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
@@ -194,0 +209,0 @@ |
@@ -17,6 +17,6 @@ const { isAbsolute, join, dirname } = require('path') | ||
if (isAbsolute(sourceMap)) { | ||
return sourceMap | ||
return sourceMap.trim() | ||
} else { | ||
const base = dirname(file) | ||
return join(base, sourceMap) | ||
return join(base, sourceMap).trim() | ||
} | ||
@@ -23,0 +23,0 @@ } |
{ | ||
"name": "c8", | ||
"version": "7.1.2", | ||
"version": "7.2.0-beta.0", | ||
"description": "output coverage reports using Node.js' built in coverage", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
38053
589
2