xref: /expo/tools/src/vendoring/devmenu/steps/Print.ts (revision 1915f6b4)
1import { Task } from './Task';
2
3export enum MessageType {
4  INFO,
5  WARNING,
6}
7
8export class Print extends Task {
9  private readonly messageType: MessageType;
10  private readonly message: string;
11
12  constructor(messageType: MessageType, message: string) {
13    super();
14    this.messageType = messageType;
15    this.message = message;
16  }
17
18  protected execute(): Promise<void> {
19    this.getLogFunction()(this.message);
20    return Promise.resolve();
21  }
22
23  private getLogFunction(): (message: string) => void {
24    switch (this.messageType) {
25      case MessageType.INFO:
26        return console.log;
27      case MessageType.WARNING:
28        return console.warn;
29      default:
30        return console.log;
31    }
32  }
33}
34