type-coverage-core
Advanced tools
Comparing version 2.16.2 to 2.16.3
@@ -113,8 +113,25 @@ "use strict"; | ||
async function getRootNames(config, dirname) { | ||
var _a, _b; | ||
const include = config.include; | ||
// exclude only works when include exists: https://www.typescriptlang.org/tsconfig#exclude | ||
const exclude = include ? config.exclude || ['node_modules/**'] : ['node_modules/**']; | ||
var _a, _b, _c; | ||
// https://www.typescriptlang.org/tsconfig#include | ||
let include; | ||
if (config.include) { | ||
include = config.include; | ||
} | ||
else { | ||
include = config.files ? [] : ['**/*']; | ||
} | ||
// https://www.typescriptlang.org/tsconfig#files | ||
const files = (_b = (_a = config.files) === null || _a === void 0 ? void 0 : _a.map(f => path.resolve(dirname, f))) !== null && _b !== void 0 ? _b : []; | ||
if (include && Array.isArray(include) && include.length > 0) { | ||
if (Array.isArray(include) && include.length > 0) { | ||
// https://www.typescriptlang.org/tsconfig#exclude | ||
let exclude; | ||
if (config.exclude) { | ||
exclude = config.exclude; | ||
} | ||
else { | ||
exclude = ['node_modules', 'bower_components', 'jspm_packages']; | ||
if ((_c = config.compilerOptions) === null || _c === void 0 ? void 0 : _c.outDir) { | ||
exclude.push(config.compilerOptions.outDir); | ||
} | ||
} | ||
const rules = []; | ||
@@ -124,20 +141,13 @@ for (const file of include) { | ||
const stats = await statAsync(currentPath); | ||
if (stats === undefined) { | ||
if (stats === undefined || stats.isFile()) { | ||
rules.push(currentPath); | ||
} | ||
else if (stats.isDirectory()) { | ||
rules.push(`${currentPath.endsWith('/') ? currentPath.substring(0, currentPath.length - 1) : currentPath}/**/*.{ts,tsx}`); | ||
rules.push(`${currentPath.endsWith('/') ? currentPath.substring(0, currentPath.length - 1) : currentPath}/**/*`); | ||
} | ||
else if (stats.isFile()) { | ||
rules.push(currentPath); | ||
} | ||
} | ||
const includeFiles = await globAsync(rules.length === 1 ? rules[0] : `{${rules.join(',')}}`, exclude, dirname); | ||
return [...files, ...includeFiles]; | ||
files.push(...includeFiles); | ||
} | ||
if (config.files) { | ||
return files; | ||
} | ||
const rootNames = await globAsync(`**/*.{ts,tsx}`, exclude, dirname); | ||
return rootNames.map((r) => path.resolve(process.cwd(), dirname, r)); | ||
return files.map((r) => path.resolve(process.cwd(), dirname, r)); | ||
} | ||
@@ -144,0 +154,0 @@ function statAsync(file) { |
{ | ||
"name": "type-coverage-core", | ||
"version": "2.16.2", | ||
"version": "2.16.3", | ||
"description": "A library to check type coverage for typescript code", | ||
@@ -5,0 +5,0 @@ "main": "dist/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
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
54094
1541