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