Skip to content

Commit 20f0b50

Browse files
committed
fix: Ensure compatibility with Node 18/20 by safely importing styleText from util
1 parent 6c866a9 commit 20f0b50

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

cli/utils/interactive-menu.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { readdirSync } from 'node:fs';
22
import { join, resolve } from 'node:path';
3-
import { styleText } from 'node:util';
3+
// `styleText` is only available in Node 21+. To stay compatible with Node 18/20
4+
// we safely import the entire util namespace and fall back to a no-op when
5+
// `styleText` is not present.
6+
import * as util from 'node:util';
7+
const styleText = util.styleText ?? ((_, text) => text);
48
/**
59
* Finds all rules in category and prepares them for display in menu
610
* @param {Record<string, Array<{name: string, path: string, fullPath: string}>>} rules

0 commit comments

Comments
 (0)