Skip to content

Commit

Permalink
moved type to types file
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-byb committed Apr 18, 2023
1 parent 5c25fd0 commit 5ac7551
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Layer,
Packager,
Config,
Level,
LevelName,
TransformedLayerResources,
Maybe,
FunctionLayerReference,
Expand All @@ -35,7 +35,7 @@ class EsbuildLayersPlugin implements Plugin {
region: string;
packager: Packager;
config: Config;
level: keyof typeof Level;
level: LevelName;
log: Plugin.Logging['log'];
installedLayerNames: Set<string>;

Expand Down
10 changes: 5 additions & 5 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Level } from './types';
import { Level, LevelName } from './types';
import type Plugin from 'serverless/classes/Plugin';

export function log(...s: unknown[]) {
Expand All @@ -11,19 +11,19 @@ export function warn(...s: unknown[]) {
console.warn('[esbuild-layers]', ...s);
}

export function verbose({ level }: { level: keyof typeof Level }, ...s: unknown[]) {
export function verbose({ level }: { level: LevelName }, ...s: unknown[]) {
Number(Level[level]) >= Level.verbose && log(...s);
}

export function info({ level }: { level: keyof typeof Level }, ...s: unknown[]) {
export function info({ level }: { level: LevelName }, ...s: unknown[]) {
Number(Level[level]) >= Level.info && log(...s);
}

export function debug({ level }: { level: keyof typeof Level }, ...s: unknown[]) {
export function debug({ level }: { level: LevelName }, ...s: unknown[]) {
Number(Level[level]) >= Level.debug && log(...s);
}

export const Log = (level: keyof typeof Level): Plugin.Logging['log'] => ({
export const Log = (level: LevelName): Plugin.Logging['log'] => ({
info: info.bind(level),
debug: debug.bind(level),
verbose: verbose.bind(level),
Expand Down
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type Packager = 'npm' | 'yarn' | 'pnpm';

export type Config = {
packager: Packager | 'auto';
level: keyof typeof Level;
level: LevelName;
clean: boolean;
minify: boolean;
};
Expand All @@ -49,3 +49,5 @@ export enum Level {
verbose = 2,
debug = 3,
}

export type LevelName = keyof typeof Level;

0 comments on commit 5ac7551

Please sign in to comment.