@plugjs/tsd
Version:
Zip File Plugin for the PlugJS Build System ===========================================
78 lines (76 loc) • 3.19 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// tsd.ts
var tsd_exports = {};
__export(tsd_exports, {
Tsd: () => Tsd
});
module.exports = __toCommonJS(tsd_exports);
var import_plug = require("@plugjs/plug");
var import_logging = require("@plugjs/plug/logging");
var import_paths = require("@plugjs/plug/paths");
var tsdLib = __toESM(require("tsd"), 1);
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 ? (0, import_plug.resolve)(_cwd) : (
/* coverage ignore next */
(0, import_paths.getCurrentWorkingDirectory)()
);
const typingsFile = _typingsFile && (0, import_paths.assertRelativeChildPath)(cwd, (0, import_plug.resolve)(_typingsFile));
const testFiles = [...import_plug.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 = (0, import_paths.resolveAbsolutePath)(cwd, fileName);
const level = severity === "warning" ? import_logging.WARN : import_logging.ERROR;
if (level === import_logging.WARN && /__file_marker__/gm.test(message)) {
report.annotate(import_logging.NOTICE, file, "mark");
} else {
report.add({ line, column, file, message, level });
}
}
await report.loadSources();
report.done(true);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Tsd
});
//# sourceMappingURL=tsd.cjs.map