fix: dont log unknown config property
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { command } from 'cleye';
|
||||
import { red } from 'kolorist';
|
||||
import { getConfig, setConfigs } from '../utils/config.js';
|
||||
import { hasOwn, getConfig, setConfigs } from '../utils/config.js';
|
||||
import { KnownError, handleCliError } from '../utils/error.js';
|
||||
|
||||
export default command({
|
||||
@@ -14,8 +14,10 @@ export default command({
|
||||
if (mode === 'get') {
|
||||
const config = await getConfig();
|
||||
for (const key of keyValues) {
|
||||
if (hasOwn(config, key)) {
|
||||
console.log(`${key}=${config[key as keyof typeof config]}`);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { fileExists } from './fs.js';
|
||||
import { KnownError } from './error.js';
|
||||
|
||||
const { hasOwnProperty } = Object.prototype;
|
||||
const hasOwn = (object: unknown, key: PropertyKey) => hasOwnProperty.call(object, key);
|
||||
export const hasOwn = (object: unknown, key: PropertyKey) => hasOwnProperty.call(object, key);
|
||||
|
||||
const parseAssert = (
|
||||
name: string,
|
||||
|
||||
@@ -50,6 +50,18 @@ export default testSuite(({ describe }) => {
|
||||
expect(stdout).toBe(openAiToken);
|
||||
});
|
||||
|
||||
await test('reading unknown config', async () => {
|
||||
await fs.appendFile(configPath, 'UNKNOWN=1');
|
||||
|
||||
const { stdout, stderr } = await execaNode(aicommitsPath, ['config', 'get', 'UNKNOWN'], {
|
||||
env,
|
||||
reject: false,
|
||||
});
|
||||
|
||||
expect(stdout).toBe('');
|
||||
expect(stderr).toBe('');
|
||||
});
|
||||
|
||||
await fixture.rm();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user