mc-publish/src/publishing/publisher.ts
2021-09-24 14:53:46 +03:00

20 lines
702 B
TypeScript

import Logger from "../utils/logger";
import { getEmptyLogger } from "../utils/logger-utils";
import PublisherTarget from "./publisher-target";
export default abstract class Publisher<TOptions> {
protected readonly options: TOptions;
protected readonly logger: Logger;
public constructor(options: TOptions, logger?: Logger) {
if (!options || typeof options !== "object") {
throw new Error(`Expected options to be an object, got ${options ? typeof options : options}`);
}
this.options = options;
this.logger = logger || getEmptyLogger();
}
public abstract get target(): PublisherTarget;
public abstract publish(): Promise<void>;
}