Skip to content

Commit e03c138

Browse files
committed
chore: update
1 parent 51fb323 commit e03c138

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

packages/core/src/cli/initConfig.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,10 @@ import type {
88
RslibConfig,
99
} from '../types';
1010
import { getAbsolutePath } from '../utils/helper';
11-
import { logger } from '../utils/logger';
11+
import { isDebugKey, logger } from '../utils/logger';
1212
import type { BuildOptions, CommonOptions } from './commands';
1313
import { onBeforeRestart } from './restart';
1414

15-
const shouldPrintSerializedRslibConfig = (): boolean => {
16-
if (!process.env.DEBUG) {
17-
return false;
18-
}
19-
20-
const values = process.env.DEBUG.toLocaleLowerCase().split(',');
21-
return ['rslib'].some((key) => values.includes(key));
22-
};
23-
2415
const getEnvDir = (cwd: string, envDir?: string) => {
2516
if (envDir) {
2617
return path.isAbsolute(envDir) ? envDir : path.resolve(cwd, envDir);
@@ -151,7 +142,7 @@ export async function initConfig(options: CommonOptions): Promise<{
151142
applyCliOptions(config, options, root);
152143

153144
// only debug serialized rslib config when DEBUG=rslib
154-
if (shouldPrintSerializedRslibConfig()) {
145+
if (isDebugKey(['rslib'])) {
155146
logger.debug('Rslib config used to generate Rsbuild environments:');
156147
logger.debug(`\n${util.inspect(config, { depth: null, colors: true })}`);
157148
}

packages/core/src/utils/logger.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
import { type Logger, logger } from 'rslog';
1616
import { color } from './color';
1717

18-
export const isDebug = (): boolean => {
18+
export const isDebugKey = (keys: string[]): boolean => {
1919
if (!process.env.DEBUG) {
2020
return false;
2121
}
2222

2323
const values = process.env.DEBUG.toLocaleLowerCase().split(',');
24-
return ['rslib', 'rsbuild', 'rs*', 'rstack', '*'].some((key) =>
25-
values.includes(key),
26-
);
24+
return keys.some((key) => values.includes(key));
25+
};
26+
27+
export const isDebug = (): boolean => {
28+
return isDebugKey(['rslib', 'rsbuild', 'rs*', 'rstack', '*']);
2729
};
2830

2931
// setup the logger level

0 commit comments

Comments
 (0)