fix: dont log unknown config property

This commit is contained in:
Hiroki Osame
2023-03-10 15:39:13 +09:00
parent d6a6a5b025
commit 09c2c98e05
3 changed files with 17 additions and 3 deletions

View File

@@ -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,7 +14,9 @@ export default command({
if (mode === 'get') {
const config = await getConfig();
for (const key of keyValues) {
console.log(`${key}=${config[key as keyof typeof config]}`);
if (hasOwn(config, key)) {
console.log(`${key}=${config[key as keyof typeof config]}`);
}
}
return;
}

View File

@@ -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,