From d4d0e74c7a0cc670309ad8ddbb4c8a6f7ae9a00e Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 10 Mar 2021 23:04:12 +0100 Subject: [PATCH] refactor: dequal (#9071) --- lib/config-validator.ts | 4 ++-- lib/config/migration.ts | 4 ++-- lib/datasource/index.ts | 4 ++-- lib/manager/npm/update/dependency/index.ts | 6 +++--- lib/manager/travis/package.ts | 4 ++-- package.json | 2 +- yarn.lock | 5 +++++ 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/config-validator.ts b/lib/config-validator.ts index 161da7bed2..78350a90ee 100644 --- a/lib/config-validator.ts +++ b/lib/config-validator.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node // istanbul ignore file -import equal from 'fast-deep-equal'; +import { dequal } from 'dequal'; import { readFileSync } from 'fs-extra'; import JSON5 from 'json5'; import { configFileNames } from './config/app-strings'; @@ -89,7 +89,7 @@ type PackageJson = { } try { const fileConfig = getFileConfig(process.env); - if (!equal(fileConfig, {})) { + if (!dequal(fileConfig, {})) { const file = process.env.RENOVATE_CONFIG_FILE ?? 'config.js'; logger.info(`Validating ${file}`); try { diff --git a/lib/config/migration.ts b/lib/config/migration.ts index 423b884beb..5298460c40 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -1,6 +1,6 @@ import later from '@breejs/later'; import is from '@sindresorhus/is'; -import equal from 'fast-deep-equal'; +import { dequal } from 'dequal'; import { logger } from '../logger'; import type { HostRule } from '../types'; import { clone } from '../util/clone'; @@ -547,7 +547,7 @@ export function migrateConfig( } } } - const isMigrated = !equal(config, migratedConfig); + const isMigrated = !dequal(config, migratedConfig); if (isMigrated) { // recursive call in case any migrated configs need further migrating return { diff --git a/lib/datasource/index.ts b/lib/datasource/index.ts index 8375eb5e82..6f865853df 100644 --- a/lib/datasource/index.ts +++ b/lib/datasource/index.ts @@ -1,5 +1,5 @@ import is from '@sindresorhus/is'; -import equal from 'fast-deep-equal'; +import { dequal } from 'dequal'; import { HOST_DISABLED } from '../constants/error-messages'; import { logger } from '../logger'; import { ExternalHostError } from '../types/errors/external-host-error'; @@ -230,7 +230,7 @@ async function fetchReleases( } logError(datasource.id, config.lookupName, err); } - if (!dep || equal(dep, { releases: [] })) { + if (!dep || dequal(dep, { releases: [] })) { return null; } addMetaData(dep, datasourceName, config.lookupName); diff --git a/lib/manager/npm/update/dependency/index.ts b/lib/manager/npm/update/dependency/index.ts index 5b51094457..ed939783d9 100644 --- a/lib/manager/npm/update/dependency/index.ts +++ b/lib/manager/npm/update/dependency/index.ts @@ -1,4 +1,4 @@ -import equal from 'fast-deep-equal'; +import { dequal } from 'dequal'; import { logger } from '../../../../logger'; import { matchAt, replaceAt } from '../../../../util/string'; import type { UpdateDependencyConfig } from '../../../types'; @@ -59,7 +59,7 @@ export function updateDependency({ newString ); // Compare the parsed JSON structure of old and new - if (equal(parsedContents, JSON.parse(testContent))) { + if (dequal(parsedContents, JSON.parse(testContent))) { newFileContent = testContent; break; } @@ -114,7 +114,7 @@ export function updateDependency({ newResolution ); // Compare the parsed JSON structure of old and new - if (equal(parsedContents, JSON.parse(testContent))) { + if (dequal(parsedContents, JSON.parse(testContent))) { newFileContent = testContent; break; } diff --git a/lib/manager/travis/package.ts b/lib/manager/travis/package.ts index 6de3965486..20e1f81705 100644 --- a/lib/manager/travis/package.ts +++ b/lib/manager/travis/package.ts @@ -1,5 +1,5 @@ import is from '@sindresorhus/is'; -import equal from 'fast-deep-equal'; +import { dequal } from 'dequal'; import { getPkgReleases } from '../../datasource'; import * as datasourceGithubTags from '../../datasource/github-tags'; import { logger } from '../../logger'; @@ -47,7 +47,7 @@ export async function getPackageUpdates( // TODO: `config.currentValue` is a string! (config.currentValue as any).sort((a, b) => a - b); - if (equal(config.currentValue, newValue)) { + if (dequal(config.currentValue, newValue)) { return []; } return [ diff --git a/package.json b/package.json index b224c43536..bb54279987 100644 --- a/package.json +++ b/package.json @@ -138,9 +138,9 @@ "crypto-random-string": "3.3.1", "deepmerge": "4.2.2", "delay": "5.0.0", + "dequal": "2.0.2", "detect-indent": "6.0.0", "email-addresses": "3.1.0", - "fast-deep-equal": "3.1.3", "fast-safe-stringify": "2.0.7", "find-up": "5.0.0", "fs-extra": "9.1.0", diff --git a/yarn.lock b/yarn.lock index 7156f4d2d0..7ca62559ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3488,6 +3488,11 @@ deprecation@^2.0.0, deprecation@^2.3.1: resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== +dequal@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.2.tgz#85ca22025e3a87e65ef75a7a437b35284a7e319d" + integrity sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug== + detect-indent@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.0.0.tgz#0abd0f549f69fc6659a254fe96786186b6f528fd" -- GitLab