@tapjs/processinfo
Advanced tools
Comparing version 2.2.4 to 2.2.5
@@ -52,3 +52,3 @@ "use strict"; | ||
/* c8 ignore start */ | ||
})(exec = exports.exec || (exports.exec = {})); | ||
})(exec || (exports.exec = exec = {})); | ||
function execSync(cmd, options) { | ||
@@ -91,3 +91,3 @@ return (0, child_process_1.execSync)(cmd, (0, spawn_opts_js_1.spawnOpts)(options || {}, (0, get_exclude_js_1.getExclude)(k))); | ||
/* c8 ignore start */ | ||
})(execFile = exports.execFile || (exports.execFile = {})); | ||
})(execFile || (exports.execFile = execFile = {})); | ||
function execFileSync(file, args, options) { | ||
@@ -94,0 +94,0 @@ if (args && |
@@ -8,2 +8,3 @@ "use strict"; | ||
const get_process_info_js_1 = require("./get-process-info.js"); | ||
const line_lengths_js_1 = require("./line-lengths.js"); | ||
const kRegisterCJS = Symbol.for('@tapjs/processinfo.registerCJS'); | ||
@@ -19,6 +20,10 @@ const g = global; | ||
(0, get_process_info_js_1.getProcessInfo)().files.push(filename); | ||
(0, line_lengths_js_1.saveLineLengths)(filename, code); | ||
return code; | ||
}, { exts: ['.js', '.cjs'], matcher: filename => !exclude.test(filename) }); | ||
}, { | ||
exts: ['.js', '.cjs', '.ts', '.cts', '.jsx', '.tsx'], | ||
matcher: filename => !exclude.test(filename), | ||
}); | ||
}; | ||
exports.register = register; | ||
//# sourceMappingURL=register-cjs.js.map |
@@ -12,2 +12,3 @@ "use strict"; | ||
const get_exclude_js_1 = require("./get-exclude.js"); | ||
const line_lengths_js_1 = require("./line-lengths.js"); | ||
exports.SESSION = undefined; | ||
@@ -23,3 +24,6 @@ // NB: coverage exclusion is in addition to processinfo | ||
const cfEnv = process.env._TAPJS_PROCESSINFO_COV_FILES_ || ''; | ||
const coveredFiles = cfEnv.trim().split('\n').filter(f => !!f); | ||
const coveredFiles = cfEnv | ||
.trim() | ||
.split('\n') | ||
.filter(f => !!f); | ||
const fileCovered = (f, s, files = []) => { | ||
@@ -68,12 +72,2 @@ const testFiles = [f]; | ||
/* c8 ignore stop */ | ||
// NB: this is the *generated* line lengths, not the source | ||
const lineLengths = (f) => { | ||
try { | ||
const content = (0, fs_1.readFileSync)(f, 'utf8'); | ||
return content.split(/\n|\u2028|\u2029/).map(l => l.length); | ||
} | ||
catch { | ||
return []; | ||
} | ||
}; | ||
const coverageOnProcessEnd = (cwd, processInfo) => { | ||
@@ -116,3 +110,3 @@ // Similar to the coverage tracking bootstrap problem above, c8 | ||
sourceMapCache[obj.url] = Object.assign(Object.create(null), { | ||
lineLengths: lineLengths(f), | ||
lineLengths: (0, line_lengths_js_1.getLineLengths)(f), | ||
data: payload, | ||
@@ -119,0 +113,0 @@ }); |
@@ -5,2 +5,3 @@ // commonjs style loader hook, modifying require.extensions | ||
import { getProcessInfo } from './get-process-info.js'; | ||
import { saveLineLengths } from './line-lengths.js'; | ||
const kRegisterCJS = Symbol.for('@tapjs/processinfo.registerCJS'); | ||
@@ -16,5 +17,9 @@ const g = global; | ||
getProcessInfo().files.push(filename); | ||
saveLineLengths(filename, code); | ||
return code; | ||
}, { exts: ['.js', '.cjs'], matcher: filename => !exclude.test(filename) }); | ||
}, { | ||
exts: ['.js', '.cjs', '.ts', '.cts', '.jsx', '.tsx'], | ||
matcher: filename => !exclude.test(filename), | ||
}); | ||
}; | ||
//# sourceMappingURL=register-cjs.js.map |
// start tracking coverage, unless disabled explicltly | ||
// export so that we know to collect at the end of the process | ||
const enabled = process.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'; | ||
import { mkdirSync, readFileSync, writeFileSync } from 'fs'; | ||
import { mkdirSync, writeFileSync } from 'fs'; | ||
import { Session } from 'inspector'; | ||
@@ -9,2 +9,3 @@ import { findSourceMap } from 'module'; | ||
import { getExclude } from './get-exclude.js'; | ||
import { getLineLengths } from './line-lengths.js'; | ||
export let SESSION = undefined; | ||
@@ -20,3 +21,6 @@ // NB: coverage exclusion is in addition to processinfo | ||
const cfEnv = process.env._TAPJS_PROCESSINFO_COV_FILES_ || ''; | ||
const coveredFiles = cfEnv.trim().split('\n').filter(f => !!f); | ||
const coveredFiles = cfEnv | ||
.trim() | ||
.split('\n') | ||
.filter(f => !!f); | ||
const fileCovered = (f, s, files = []) => { | ||
@@ -64,12 +68,2 @@ const testFiles = [f]; | ||
/* c8 ignore stop */ | ||
// NB: this is the *generated* line lengths, not the source | ||
const lineLengths = (f) => { | ||
try { | ||
const content = readFileSync(f, 'utf8'); | ||
return content.split(/\n|\u2028|\u2029/).map(l => l.length); | ||
} | ||
catch { | ||
return []; | ||
} | ||
}; | ||
export const coverageOnProcessEnd = (cwd, processInfo) => { | ||
@@ -112,3 +106,3 @@ // Similar to the coverage tracking bootstrap problem above, c8 | ||
sourceMapCache[obj.url] = Object.assign(Object.create(null), { | ||
lineLengths: lineLengths(f), | ||
lineLengths: getLineLengths(f), | ||
data: payload, | ||
@@ -115,0 +109,0 @@ }); |
{ | ||
"name": "@tapjs/processinfo", | ||
"version": "2.2.4", | ||
"version": "2.2.5", | ||
"main": "./dist/cjs/index.js", | ||
@@ -88,5 +88,5 @@ "types": "./dist/cjs/index.d.ts", | ||
"typedoc": "^0.24.8", | ||
"typescript": "^5.0.4" | ||
"typescript": "^5.1.3" | ||
}, | ||
"repository": "https://github.com/tapjs/processinfo" | ||
} |
@@ -54,2 +54,10 @@ # @tapjs/processinfo | ||
### Important | ||
In order to properly track `lineLengths` (required for coverage | ||
reporting on source mapped files), `@tapjs/processinfo` must be | ||
the **last** loader specified on the command line, so that it can | ||
get access to the transpiled source that Node.js actually | ||
executes. | ||
### Interacting with Process Info | ||
@@ -56,0 +64,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
318568
149
2458
141