From e2ac9191ea7e9746abdaa0035da2a39a889736b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Catal=C3=A1n?= Date: Mon, 18 Dec 2023 09:39:11 -0500 Subject: [PATCH] chore: refactor arraynge into arraysure dependency --- package.json | 1 + src/shared/XmlParser.ts | 4 ++-- src/shared/arraynge.ts | 7 ------- yarn.lock | 5 +++++ 4 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 src/shared/arraynge.ts diff --git a/package.json b/package.json index e759d47..3a3850c 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@salesforce/sf-plugins-core": "^5.0.5", "@types/shelljs": "^0.8.15", "@types/xml2js": "^0.4.14", + "arraysure": "^1.0.1", "exceljs": "^4.4.0", "shelljs": "^0.8.5", "xml2js": "^0.6.2" diff --git a/src/shared/XmlParser.ts b/src/shared/XmlParser.ts index ba07ef5..ded2c64 100644 --- a/src/shared/XmlParser.ts +++ b/src/shared/XmlParser.ts @@ -1,7 +1,7 @@ import * as xml2js from 'xml2js'; +import { array } from 'arraysure'; import * as Metadata from '../types/metadata.js'; import { Named, FullNamed, ObjectNamed } from '../types/metadata-addon.js'; -import { arraynge } from './arraynge.js'; const nameRegEx = new RegExp('.+/([^.]*)'); const parserOptions: xml2js.ParserOptions = { @@ -75,7 +75,7 @@ export class XmlParser { const objectName = nameRegEx.exec(fileName)?.[1] as string; // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access xml2js.parseString(xml, parserOptions, (err, result: { Workflow: Metadata.Workflow }) => { - for (const thisRule of arraynge(result.Workflow.rules) as Array>>) { + for (const thisRule of array(result.Workflow.rules) as Array>>) { thisRule.objectName = objectName; workflowRules.push(thisRule); } diff --git a/src/shared/arraynge.ts b/src/shared/arraynge.ts deleted file mode 100644 index e0a42eb..0000000 --- a/src/shared/arraynge.ts +++ /dev/null @@ -1,7 +0,0 @@ -export function arraynge(input: Type | Type[] | undefined): Type[] { - if (input === undefined) { - return []; - } - - return Array.isArray(input) ? input : [input]; -} diff --git a/yarn.lock b/yarn.lock index e737351..cb8adbc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1921,6 +1921,11 @@ arraybuffer.prototype.slice@^1.0.2: is-array-buffer "^3.0.2" is-shared-array-buffer "^1.0.2" +arraysure@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arraysure/-/arraysure-1.0.1.tgz#6b4e882bd71c912f0c22e056d09599dd37c2ce58" + integrity sha512-4KNGGiOXrbDxcLbwxvWSYOX1PuYVOmnwRwu1rxiZooBk5PO49tasq51K9Iy6wM7CoBWDGPTmHimVSklpRN1JGw== + arrify@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz"