NeahNew/node_modules/dmg-license/lib/Context.js
2025-05-06 22:43:27 +02:00

43 lines
1.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Context {
constructor(options) {
this.options = options;
if (options.resolvePath)
this.resolvePath = options.resolvePath.bind(options);
}
static from(contextOrOptions) {
if (contextOrOptions instanceof Context)
return contextOrOptions;
else
return new Context(contextOrOptions);
}
resolvePath(path) {
return path;
}
nonFatalError(error, errorBuffer) {
const reporter = this.options.onNonFatalError;
if (reporter) {
if (errorBuffer)
errorBuffer.catching(() => reporter(error));
else
reporter(error);
}
else
throw error;
}
warning(error, errorBuffer) {
const reporter = this.options.onNonFatalError;
if (reporter) {
if (errorBuffer)
errorBuffer.catching(() => reporter(error));
else
reporter(error);
}
}
get canWarn() {
return !!this.options.onNonFatalError;
}
}
exports.default = Context;
//# sourceMappingURL=Context.js.map