Skip to content

Commit 5346e40

Browse files
committed
refactor: fix imports and add type guards
- Remove unused createRequire import from templates.mjs - Fix import path to use local registry build instead of @socketsecurity/lib - Add type guard for manifestData to handle array case
1 parent acaef76 commit 5346e40

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

scripts/utils/templates.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import { promises as fs } from 'node:fs'
7-
import { createRequire } from 'node:module'
87
import path from 'node:path'
98

109
import { PackageURL } from '@socketregistry/packageurl-js'

test/packages.test.mts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { fix } from '@npmcli/package-json'
66
import { parseArgs } from '@socketsecurity/lib/argv/parse'
77
import { EXT_JSON } from '@socketsecurity/lib/constants/paths'
88
import { readJson } from '@socketsecurity/lib/fs'
9-
import { getManifestData } from '@socketsecurity/lib/index'
109
import { isObjectObject, objectEntries } from '@socketsecurity/lib/objects'
1110
import {
1211
getExportFilePaths,
@@ -20,6 +19,8 @@ import { isNonEmptyString } from '@socketsecurity/lib/strings'
2019
import fastGlob from 'fast-glob'
2120
import semver from 'semver'
2221
import { describe, expect, it } from 'vitest'
22+
23+
import { getManifestData } from '../registry/src/index.js'
2324
import {
2425
LICENSE,
2526
NPM,
@@ -260,7 +261,11 @@ for (const eco of ecosystems) {
260261
})
261262

262263
const manifestData = getManifestData(eco, sockRegPkgName)
263-
if (manifestData?.license !== 'Public Domain') {
264+
if (
265+
manifestData &&
266+
!Array.isArray(manifestData) &&
267+
manifestData.license !== 'Public Domain'
268+
) {
264269
it('should have an original license file', () => {
265270
expect(files.some(p => p.includes('.original'))).toBe(true)
266271
})

0 commit comments

Comments
 (0)