UNPKG

@plugjs/tsd

Version:

Zip File Plugin for the PlugJS Build System ===========================================

43 lines (42 loc) 1.5 kB
// tsd.ts import { Files, resolve } from "@plugjs/plug"; import { ERROR, NOTICE, WARN } from "@plugjs/plug/logging"; import { assertRelativeChildPath, getCurrentWorkingDirectory, resolveAbsolutePath } from "@plugjs/plug/paths"; import * as tsdLib from "tsd"; var tsd = tsdLib.default.default ? tsdLib.default.default : tsdLib.default; var Tsd = class { constructor(_options = {}) { this._options = _options; } async pipe(files, context) { const { cwd: _cwd, typingsFile: _typingsFile } = this._options; const cwd = _cwd ? resolve(_cwd) : ( /* coverage ignore next */ getCurrentWorkingDirectory() ); const typingsFile = _typingsFile && assertRelativeChildPath(cwd, resolve(_typingsFile)); const testFiles = [...Files.builder(cwd).add(...files.absolutePaths()).build()]; const diagnostics = await tsd({ cwd, typingsFile, testFiles }); const report = context.log.report("Typescript Definitions Test"); for (const diag of diagnostics) { const { fileName, column, line, message, severity } = diag; const file = resolveAbsolutePath(cwd, fileName); const level = severity === "warning" ? WARN : ERROR; if (level === WARN && /__file_marker__/gm.test(message)) { report.annotate(NOTICE, file, "mark"); } else { report.add({ line, column, file, message, level }); } } await report.loadSources(); report.done(true); } }; export { Tsd }; //# sourceMappingURL=tsd.mjs.map