mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
test: Make oclif commands testable (#3571)
* ➕ Add `@oclif/core` * 📦 Update `package-lock.json` * 📘 Export `Logger` for use as type * ✨ Create `BaseCommand` * 🐛 Prevent DB re-init * ♻️ Refactor `reset` command * 🧪 Fix `reset` test * 👕 Add lint exception Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-shadow */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
|
||||
import { inspect } from 'util';
|
||||
import winston from 'winston';
|
||||
|
||||
@@ -11,7 +12,7 @@ import callsites from 'callsites';
|
||||
import { basename } from 'path';
|
||||
import config from '../config';
|
||||
|
||||
class Logger implements ILogger {
|
||||
export class Logger implements ILogger {
|
||||
private logger: winston.Logger;
|
||||
|
||||
constructor() {
|
||||
@@ -71,7 +72,7 @@ class Logger implements ILogger {
|
||||
}
|
||||
}
|
||||
|
||||
log(type: LogTypes, message: string, meta: object = {}) {
|
||||
log(type: LogTypes, message: string, meta: object = {}): void {
|
||||
const callsite = callsites();
|
||||
// We are using the third array element as the structure is as follows:
|
||||
// [0]: this file
|
||||
@@ -93,23 +94,23 @@ class Logger implements ILogger {
|
||||
|
||||
// Convenience methods below
|
||||
|
||||
debug(message: string, meta: object = {}) {
|
||||
debug(message: string, meta: object = {}): void {
|
||||
this.log('debug', message, meta);
|
||||
}
|
||||
|
||||
info(message: string, meta: object = {}) {
|
||||
info(message: string, meta: object = {}): void {
|
||||
this.log('info', message, meta);
|
||||
}
|
||||
|
||||
error(message: string, meta: object = {}) {
|
||||
error(message: string, meta: object = {}): void {
|
||||
this.log('error', message, meta);
|
||||
}
|
||||
|
||||
verbose(message: string, meta: object = {}) {
|
||||
verbose(message: string, meta: object = {}): void {
|
||||
this.log('verbose', message, meta);
|
||||
}
|
||||
|
||||
warn(message: string, meta: object = {}) {
|
||||
warn(message: string, meta: object = {}): void {
|
||||
this.log('warn', message, meta);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user