Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support consola/utils subpath #149

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};