From f1a5fecbf202aecc2177a82568681d5a13db64bb Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 15 Oct 2025 08:59:44 +0100 Subject: [PATCH 1/7] fix: only use linux/x64 optional dependencies --- src/checks/dependency-size.ts | 40 +++++++++++++++++++++++++++++++++-- src/npm.ts | 2 ++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/checks/dependency-size.ts b/src/checks/dependency-size.ts index e1811c8..dd7920a 100644 --- a/src/checks/dependency-size.ts +++ b/src/checks/dependency-size.ts @@ -1,12 +1,17 @@ import * as core from '@actions/core'; -import {calculateTotalDependencySizeIncrease} from '../npm.js'; +import {type ParsedLockFile, traverse} from 'lockparse'; +import { + calculateTotalDependencySizeIncrease, + fetchPackageMetadata +} from '../npm.js'; import {formatBytes} from '../common.js'; export async function scanForDependencySize( messages: string[], threshold: number, currentDeps: Map>, - baseDeps: Map> + baseDeps: Map>, + currentLockFile: ParsedLockFile ): Promise { const newVersions: Array<{ name: string; @@ -17,6 +22,37 @@ export async function scanForDependencySize( name: string; version: string; }> = []; + const skippedVersions = new Map>(); + const allOptionalVersions = new Map>(); + + for (const pkg of currentLockFile.packages) { + traverse(pkg, { + optionalDependency: (node) => { + const entry = allOptionalVersions.get(node.name) ?? new Set(); + entry.add(node.version); + allOptionalVersions.set(node.name, entry); + } + }); + } + + for (const [pkg, versions] of allOptionalVersions) { + for (const version of versions) { + const pkgMeta = await fetchPackageMetadata(pkg, version); + if ( + pkgMeta && + ((pkgMeta.os && + pkgMeta.os.length > 0 && + !pkgMeta.os.includes('linux')) || + (pkgMeta.cpu && + pkgMeta.cpu.length > 0 && + !pkgMeta.cpu.includes('x64'))) + ) { + const entry = skippedVersions.get(pkg) ?? new Set(); + entry.add(version); + skippedVersions.set(pkg, entry); + } + } + } for (const [packageName, currentVersionSet] of currentDeps) { const baseVersionSet = baseDeps.get(packageName); diff --git a/src/npm.ts b/src/npm.ts index 0fdd85a..02998d2 100644 --- a/src/npm.ts +++ b/src/npm.ts @@ -4,6 +4,8 @@ import type {PackageJson} from 'pkg-types'; export interface PackageMetadata { name: string; version: string; + os?: string[]; + cpu?: string[]; dist?: { unpackedSize?: number; attestations?: { From 5f3e96d0d13811ee5e0dd39def121c2452bfa872 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:04:34 +0100 Subject: [PATCH 2/7] fix: add missing build --- build/main.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/main.ts | 8 +++++++- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/build/main.js b/build/main.js index a5d3f36..770558f 100644 --- a/build/main.js +++ b/build/main.js @@ -24375,6 +24375,25 @@ function processDependencies(rootInfo, root, packageMap, prefix) { } } +// node_modules/lockparse/lib/traverse.js +var visitorKeys = [ + ["dependency", "dependencies"], + ["devDependency", "devDependencies"], + ["peerDependency", "peerDependencies"], + ["optionalDependency", "optionalDependencies"] +]; +function traverse(node, visitor) { + for (const [visitorKey, nodeKey] of visitorKeys) { + if (visitor[visitorKey]) { + for (const dep of node[nodeKey]) { + if (visitor[visitorKey](dep, node) !== false) { + traverse(dep, visitor); + } + } + } + } +} + // node_modules/lockparse/lib/main.js var typeMap = { "package-lock.json": "npm", @@ -24878,9 +24897,30 @@ function formatBytes(bytes) { } // src/checks/dependency-size.ts -async function scanForDependencySize(messages, threshold, currentDeps, baseDeps) { +async function scanForDependencySize(messages, threshold, currentDeps, baseDeps, currentLockFile) { const newVersions = []; const removedVersions = []; + const skippedVersions = /* @__PURE__ */ new Map(); + const allOptionalVersions = /* @__PURE__ */ new Map(); + for (const pkg of currentLockFile.packages) { + traverse(pkg, { + optionalDependency: (node) => { + const entry = allOptionalVersions.get(node.name) ?? /* @__PURE__ */ new Set(); + entry.add(node.version); + allOptionalVersions.set(node.name, entry); + } + }); + } + for (const [pkg, versions] of allOptionalVersions) { + for (const version of versions) { + const pkgMeta = await fetchPackageMetadata(pkg, version); + if (pkgMeta && (pkgMeta.os && pkgMeta.os.length > 0 && !pkgMeta.os.includes("linux") || pkgMeta.cpu && pkgMeta.cpu.length > 0 && !pkgMeta.cpu.includes("x64"))) { + const entry = skippedVersions.get(pkg) ?? /* @__PURE__ */ new Set(); + entry.add(version); + skippedVersions.set(pkg, entry); + } + } + } for (const [packageName, currentVersionSet] of currentDeps) { const baseVersionSet = baseDeps.get(packageName); for (const version of currentVersionSet) { @@ -25113,7 +25153,13 @@ async function run() { baseDeps ); scanForDuplicates(messages, duplicateThreshold, currentDeps, lockfilePath); - await scanForDependencySize(messages, sizeThreshold, currentDeps, baseDeps); + await scanForDependencySize( + messages, + sizeThreshold, + currentDeps, + baseDeps, + parsedCurrentLock + ); await scanForProvenance(messages, currentDeps, baseDeps); const basePackagesPattern = core7.getInput("base-packages"); const sourcePackagesPattern = core7.getInput("source-packages"); diff --git a/src/main.ts b/src/main.ts index fcf308d..07485ed 100644 --- a/src/main.ts +++ b/src/main.ts @@ -130,7 +130,13 @@ async function run(): Promise { ); scanForDuplicates(messages, duplicateThreshold, currentDeps, lockfilePath); - await scanForDependencySize(messages, sizeThreshold, currentDeps, baseDeps); + await scanForDependencySize( + messages, + sizeThreshold, + currentDeps, + baseDeps, + parsedCurrentLock + ); await scanForProvenance(messages, currentDeps, baseDeps); const basePackagesPattern = core.getInput('base-packages'); From 5a3a860621514de66475ad19f23bfec80659906c Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:13:41 +0100 Subject: [PATCH 3/7] fix: only remove optionals if new deps --- build/main.js | 46 +++++++++++++----------- src/checks/dependency-size.ts | 67 +++++++++++++++++++---------------- 2 files changed, 61 insertions(+), 52 deletions(-) diff --git a/build/main.js b/build/main.js index 770558f..82f0d38 100644 --- a/build/main.js +++ b/build/main.js @@ -24900,27 +24900,6 @@ function formatBytes(bytes) { async function scanForDependencySize(messages, threshold, currentDeps, baseDeps, currentLockFile) { const newVersions = []; const removedVersions = []; - const skippedVersions = /* @__PURE__ */ new Map(); - const allOptionalVersions = /* @__PURE__ */ new Map(); - for (const pkg of currentLockFile.packages) { - traverse(pkg, { - optionalDependency: (node) => { - const entry = allOptionalVersions.get(node.name) ?? /* @__PURE__ */ new Set(); - entry.add(node.version); - allOptionalVersions.set(node.name, entry); - } - }); - } - for (const [pkg, versions] of allOptionalVersions) { - for (const version of versions) { - const pkgMeta = await fetchPackageMetadata(pkg, version); - if (pkgMeta && (pkgMeta.os && pkgMeta.os.length > 0 && !pkgMeta.os.includes("linux") || pkgMeta.cpu && pkgMeta.cpu.length > 0 && !pkgMeta.cpu.includes("x64"))) { - const entry = skippedVersions.get(pkg) ?? /* @__PURE__ */ new Set(); - entry.add(version); - skippedVersions.set(pkg, entry); - } - } - } for (const [packageName, currentVersionSet] of currentDeps) { const baseVersionSet = baseDeps.get(packageName); for (const version of currentVersionSet) { @@ -24944,6 +24923,31 @@ async function scanForDependencySize(messages, threshold, currentDeps, baseDeps, } } } + if (newVersions.length > 0) { + const allOptionalVersions = /* @__PURE__ */ new Map(); + for (const pkg of currentLockFile.packages) { + traverse(pkg, { + optionalDependency: (node) => { + const entry = allOptionalVersions.get(node.name) ?? /* @__PURE__ */ new Set(); + entry.add(node.version); + allOptionalVersions.set(node.name, entry); + } + }); + } + for (const [pkg, versions] of allOptionalVersions) { + for (const version of versions) { + const pkgMeta = await fetchPackageMetadata(pkg, version); + if (pkgMeta && (pkgMeta.os && pkgMeta.os.length > 0 && !pkgMeta.os.includes("linux") || pkgMeta.cpu && pkgMeta.cpu.length > 0 && !pkgMeta.cpu.includes("x64"))) { + const entry = newVersions.findIndex( + (v) => v.name === pkg && v.version === version + ); + if (entry !== -1) { + newVersions.splice(entry, 1); + } + } + } + } + } core5.info(`Found ${newVersions.length} new package versions`); core5.info(`Found ${removedVersions.length} removed package versions.`); if (newVersions.length === 0 && removedVersions.length === 0) { diff --git a/src/checks/dependency-size.ts b/src/checks/dependency-size.ts index dd7920a..168d958 100644 --- a/src/checks/dependency-size.ts +++ b/src/checks/dependency-size.ts @@ -22,37 +22,6 @@ export async function scanForDependencySize( name: string; version: string; }> = []; - const skippedVersions = new Map>(); - const allOptionalVersions = new Map>(); - - for (const pkg of currentLockFile.packages) { - traverse(pkg, { - optionalDependency: (node) => { - const entry = allOptionalVersions.get(node.name) ?? new Set(); - entry.add(node.version); - allOptionalVersions.set(node.name, entry); - } - }); - } - - for (const [pkg, versions] of allOptionalVersions) { - for (const version of versions) { - const pkgMeta = await fetchPackageMetadata(pkg, version); - if ( - pkgMeta && - ((pkgMeta.os && - pkgMeta.os.length > 0 && - !pkgMeta.os.includes('linux')) || - (pkgMeta.cpu && - pkgMeta.cpu.length > 0 && - !pkgMeta.cpu.includes('x64'))) - ) { - const entry = skippedVersions.get(pkg) ?? new Set(); - entry.add(version); - skippedVersions.set(pkg, entry); - } - } - } for (const [packageName, currentVersionSet] of currentDeps) { const baseVersionSet = baseDeps.get(packageName); @@ -81,6 +50,42 @@ export async function scanForDependencySize( } } + if (newVersions.length > 0) { + const allOptionalVersions = new Map>(); + + for (const pkg of currentLockFile.packages) { + traverse(pkg, { + optionalDependency: (node) => { + const entry = allOptionalVersions.get(node.name) ?? new Set(); + entry.add(node.version); + allOptionalVersions.set(node.name, entry); + } + }); + } + + for (const [pkg, versions] of allOptionalVersions) { + for (const version of versions) { + const pkgMeta = await fetchPackageMetadata(pkg, version); + if ( + pkgMeta && + ((pkgMeta.os && + pkgMeta.os.length > 0 && + !pkgMeta.os.includes('linux')) || + (pkgMeta.cpu && + pkgMeta.cpu.length > 0 && + !pkgMeta.cpu.includes('x64'))) + ) { + const entry = newVersions.findIndex( + (v) => v.name === pkg && v.version === version + ); + if (entry !== -1) { + newVersions.splice(entry, 1); + } + } + } + } + } + core.info(`Found ${newVersions.length} new package versions`); core.info(`Found ${removedVersions.length} removed package versions.`); From c449fa5ce9463b3c6eebd33823ab4bf0934a6d47 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:24:46 +0100 Subject: [PATCH 4/7] fix: extract arch test --- build/main.js | 8 +++++++- src/checks/dependency-size.ts | 10 +++------- src/npm.ts | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/build/main.js b/build/main.js index 82f0d38..7a9b7f6 100644 --- a/build/main.js +++ b/build/main.js @@ -24630,6 +24630,12 @@ function getDependenciesFromPackageJson(pkg, types) { } return result; } +function isSupportedArchitecture(pkg, os, cpu, libc) { + const osMatches = pkg.os === void 0 || pkg.os.length > 0 && pkg.os.includes(os); + const cpuMatches = pkg.cpu === void 0 || pkg.cpu.length > 0 && pkg.cpu.includes(cpu); + const libcMatches = pkg.libc === void 0 || pkg.libc.length > 0 && pkg.libc.includes(libc); + return osMatches && cpuMatches && libcMatches; +} // src/packs.ts var core3 = __toESM(require_core(), 1); @@ -24937,7 +24943,7 @@ async function scanForDependencySize(messages, threshold, currentDeps, baseDeps, for (const [pkg, versions] of allOptionalVersions) { for (const version of versions) { const pkgMeta = await fetchPackageMetadata(pkg, version); - if (pkgMeta && (pkgMeta.os && pkgMeta.os.length > 0 && !pkgMeta.os.includes("linux") || pkgMeta.cpu && pkgMeta.cpu.length > 0 && !pkgMeta.cpu.includes("x64"))) { + if (pkgMeta && isSupportedArchitecture(pkgMeta, "linux", "x64", "glibc")) { const entry = newVersions.findIndex( (v) => v.name === pkg && v.version === version ); diff --git a/src/checks/dependency-size.ts b/src/checks/dependency-size.ts index 168d958..b2c1b1d 100644 --- a/src/checks/dependency-size.ts +++ b/src/checks/dependency-size.ts @@ -2,7 +2,8 @@ import * as core from '@actions/core'; import {type ParsedLockFile, traverse} from 'lockparse'; import { calculateTotalDependencySizeIncrease, - fetchPackageMetadata + fetchPackageMetadata, + isSupportedArchitecture } from '../npm.js'; import {formatBytes} from '../common.js'; @@ -68,12 +69,7 @@ export async function scanForDependencySize( const pkgMeta = await fetchPackageMetadata(pkg, version); if ( pkgMeta && - ((pkgMeta.os && - pkgMeta.os.length > 0 && - !pkgMeta.os.includes('linux')) || - (pkgMeta.cpu && - pkgMeta.cpu.length > 0 && - !pkgMeta.cpu.includes('x64'))) + isSupportedArchitecture(pkgMeta, 'linux', 'x64', 'glibc') ) { const entry = newVersions.findIndex( (v) => v.name === pkg && v.version === version diff --git a/src/npm.ts b/src/npm.ts index 02998d2..89b3e75 100644 --- a/src/npm.ts +++ b/src/npm.ts @@ -6,6 +6,7 @@ export interface PackageMetadata { version: string; os?: string[]; cpu?: string[]; + libc?: string[]; dist?: { unpackedSize?: number; attestations?: { @@ -220,3 +221,18 @@ export function getDependenciesFromPackageJson( return result; } + +export function isSupportedArchitecture( + pkg: PackageJson, + os: string, + cpu: string, + libc: string +): boolean { + const osMatches = + pkg.os === undefined || (pkg.os.length > 0 && pkg.os.includes(os)); + const cpuMatches = + pkg.cpu === undefined || (pkg.cpu.length > 0 && pkg.cpu.includes(cpu)); + const libcMatches = + pkg.libc === undefined || (pkg.libc.length > 0 && pkg.libc.includes(libc)); + return osMatches && cpuMatches && libcMatches; +} From 419fb0f2e605803bf22eb0e17f4f448e81d2892e Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:28:02 +0100 Subject: [PATCH 5/7] fix: allow empty fields --- build/main.js | 6 +++--- src/npm.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/main.js b/build/main.js index 7a9b7f6..7d2ec2a 100644 --- a/build/main.js +++ b/build/main.js @@ -24631,9 +24631,9 @@ function getDependenciesFromPackageJson(pkg, types) { return result; } function isSupportedArchitecture(pkg, os, cpu, libc) { - const osMatches = pkg.os === void 0 || pkg.os.length > 0 && pkg.os.includes(os); - const cpuMatches = pkg.cpu === void 0 || pkg.cpu.length > 0 && pkg.cpu.includes(cpu); - const libcMatches = pkg.libc === void 0 || pkg.libc.length > 0 && pkg.libc.includes(libc); + const osMatches = pkg.os === void 0 || pkg.os.length === 0 || pkg.os.includes(os); + const cpuMatches = pkg.cpu === void 0 || pkg.cpu.length === 0 || pkg.cpu.includes(cpu); + const libcMatches = pkg.libc === void 0 || pkg.libc.length === 0 || pkg.libc.includes(libc); return osMatches && cpuMatches && libcMatches; } diff --git a/src/npm.ts b/src/npm.ts index 89b3e75..068cba6 100644 --- a/src/npm.ts +++ b/src/npm.ts @@ -229,10 +229,10 @@ export function isSupportedArchitecture( libc: string ): boolean { const osMatches = - pkg.os === undefined || (pkg.os.length > 0 && pkg.os.includes(os)); + pkg.os === undefined || pkg.os.length === 0 || pkg.os.includes(os); const cpuMatches = - pkg.cpu === undefined || (pkg.cpu.length > 0 && pkg.cpu.includes(cpu)); + pkg.cpu === undefined || pkg.cpu.length === 0 || pkg.cpu.includes(cpu); const libcMatches = - pkg.libc === undefined || (pkg.libc.length > 0 && pkg.libc.includes(libc)); + pkg.libc === undefined || pkg.libc.length === 0 || pkg.libc.includes(libc); return osMatches && cpuMatches && libcMatches; } From 1cb7a1915f4d75c7d06a2ba6849f2000cf95cad6 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:32:43 +0100 Subject: [PATCH 6/7] fix: reverse condition --- build/main.js | 2 +- src/checks/dependency-size.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/main.js b/build/main.js index 7d2ec2a..c94966d 100644 --- a/build/main.js +++ b/build/main.js @@ -24943,7 +24943,7 @@ async function scanForDependencySize(messages, threshold, currentDeps, baseDeps, for (const [pkg, versions] of allOptionalVersions) { for (const version of versions) { const pkgMeta = await fetchPackageMetadata(pkg, version); - if (pkgMeta && isSupportedArchitecture(pkgMeta, "linux", "x64", "glibc")) { + if (pkgMeta && !isSupportedArchitecture(pkgMeta, "linux", "x64", "glibc")) { const entry = newVersions.findIndex( (v) => v.name === pkg && v.version === version ); diff --git a/src/checks/dependency-size.ts b/src/checks/dependency-size.ts index b2c1b1d..9f3cad9 100644 --- a/src/checks/dependency-size.ts +++ b/src/checks/dependency-size.ts @@ -69,7 +69,7 @@ export async function scanForDependencySize( const pkgMeta = await fetchPackageMetadata(pkg, version); if ( pkgMeta && - isSupportedArchitecture(pkgMeta, 'linux', 'x64', 'glibc') + !isSupportedArchitecture(pkgMeta, 'linux', 'x64', 'glibc') ) { const entry = newVersions.findIndex( (v) => v.name === pkg && v.version === version From f9ae4928778d7cc778a6436248a977c4963d1e19 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:59:32 +0100 Subject: [PATCH 7/7] test: add arch tests --- test/npm_test.ts | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/test/npm_test.ts b/test/npm_test.ts index e1678dc..ee41dd3 100644 --- a/test/npm_test.ts +++ b/test/npm_test.ts @@ -1,4 +1,5 @@ import * as core from '@actions/core'; +import type {PackageJson} from 'pkg-types'; import { describe, it, @@ -14,6 +15,7 @@ import { getProvenance, getTrustLevel, getProvenanceForPackageVersions, + isSupportedArchitecture, getMinTrustLevel, getDependenciesFromPackageJson, type ProvenanceStatus, @@ -294,3 +296,94 @@ describe('getDependenciesFromPackageJson', () => { ); }); }); + +describe('isSupportedArchitecture', () => { + it('returns true if no os, cpu, or libc fields are present', () => { + const pkg: PackageJson = { + name: 'some-package' + }; + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'glibc')).toBe(true); + }); + + it('returns true if os matches, cpu/libc empty', () => { + const pkg: PackageJson = { + name: 'some-package', + os: ['linux', 'darwin'] + }; + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'darwin', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'win32', 'x64', 'glibc')).toBe(false); + }); + + it('returns true if cpu matches, os/libc empty', () => { + const pkg: PackageJson = { + name: 'some-package', + cpu: ['x64', 'arm64'] + }; + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'arm64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'ia32', 'glibc')).toBe(false); + }); + + it('returns true if libc matches, os/cpu empty', () => { + const pkg: PackageJson = { + name: 'some-package', + libc: ['glibc', 'musl'] + }; + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'musl')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'uclibc')).toBe(false); + }); + + it('returns true if all match', () => { + const pkg: PackageJson = { + name: 'some-package', + os: ['linux', 'darwin'], + cpu: ['x64', 'arm64'], + libc: ['glibc', 'musl'] + }; + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'darwin', 'arm64', 'musl')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'ia32', 'glibc')).toBe(false); + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'uclibc')).toBe(false); + expect(isSupportedArchitecture(pkg, 'win32', 'x64', 'glibc')).toBe(false); + }); + + it('returns true if os is empty array', () => { + const pkg: PackageJson = { + name: 'some-package', + os: [], + cpu: ['x64'], + libc: ['glibc'] + }; + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'darwin', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'win32', 'x64', 'glibc')).toBe(true); + }); + + it('returns true if cpu is empty array', () => { + const pkg: PackageJson = { + name: 'some-package', + os: ['linux'], + cpu: [], + libc: ['glibc'] + }; + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'arm64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'ia32', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'darwin', 'x64', 'glibc')).toBe(false); + }); + + it('returns true if libc is empty array', () => { + const pkg: PackageJson = { + name: 'some-package', + os: ['linux'], + cpu: ['x64'], + libc: [] + }; + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'glibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'musl')).toBe(true); + expect(isSupportedArchitecture(pkg, 'linux', 'x64', 'uclibc')).toBe(true); + expect(isSupportedArchitecture(pkg, 'darwin', 'x64', 'glibc')).toBe(false); + }); +});