Skip to content

Commit

Permalink
feat: support consola/utils subpath (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Nov 22, 2023
1 parent 5917a50 commit f79a091
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/runtime/npm/consola/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
type ConsolaUtils = typeof import("consola/utils");

// TODO: https://github.com/unjs/consola/issues/263

const _colorize = String;

export const colorize: ConsolaUtils["colorize"] = (color, str) =>
_colorize(str);

export const getColor: ConsolaUtils["getColor"] = (color, fallback) => () =>
_colorize(color);

export const stripAnsi: ConsolaUtils["stripAnsi"] = (str) => str;

export const box: ConsolaUtils["box"] = (str, opts) => str;

export const align: ConsolaUtils["align"] = (alignment, str, len, space) => str;
export const leftAlign: ConsolaUtils["leftAlign"] = (str, len, space?) => str;
export const rightAlign: ConsolaUtils["rightAlign"] = (str, len, space?) => str;
export const centerAlign: ConsolaUtils["centerAlign"] = (str, len, space?) =>
str;

export const colors = new Proxy<ConsolaUtils["colors"]>({} as any, {
get(_, colorName) {
return _colorize;
},
});

export default <ConsolaUtils>{
colorize,
getColor,
stripAnsi,
align,
leftAlign,
rightAlign,
centerAlign,
box,
colors,
};

0 comments on commit f79a091

Please sign in to comment.