Skip to content

Commit

Permalink
Merge pull request #64 from HubSpot/fix-table-bug
Browse files Browse the repository at this point in the history
Fix bug with isObject
  • Loading branch information
camden11 authored Nov 14, 2023
2 parents 6a1ed62 + 7005327 commit 661ddee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/cms/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import findup from 'findup-sync';
import { getCwd } from '../path';
import { downloadGithubRepoContents } from '../github';
import { debug, makeTypedLogger } from '../../utils/logger';
import { isObject } from '../../utils/objectUtils';
import { throwErrorWithMessage } from '../../errors/standardErrors';
import { throwFileSystemError } from '../../errors/fileSystemErrors';
import { BaseError } from '../../types/Error';
Expand All @@ -25,6 +24,11 @@ type Config = {
};
};

function isObjectOrFunction(value: object): boolean {
const type = typeof value;
return value != null && (type === 'object' || type === 'function');
}

function createEndpoint(
endpointMethod: string,
filename: string
Expand Down Expand Up @@ -92,7 +96,7 @@ function updateExistingConfig(
});
}

if (!isObject(config)) {
if (!isObjectOrFunction(config)) {
throwErrorWithMessage(
`${i18nKey}.updateExistingConfig.errors.configIsNotObjectError`,
{ configFilePath }
Expand Down
6 changes: 3 additions & 3 deletions utils/objectUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function isObject(value: object): boolean {
const type = typeof value;
return value != null && (type === 'object' || type === 'function');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isObject(item: any) {
return item && typeof item === 'object' && !Array.isArray(item);
}

export function mergeDeep(
Expand Down

0 comments on commit 661ddee

Please sign in to comment.