From fed35841e0151ad5dff57f087fd9ad5c3625344b Mon Sep 17 00:00:00 2001 From: Tadas Dailyda Date: Thu, 15 Dec 2022 12:53:26 +0200 Subject: [PATCH] cli: 'artifacts' command update to deal with universal builds --- cli/src/artifacts.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cli/src/artifacts.ts b/cli/src/artifacts.ts index a09bbb5c..1d71e39e 100644 --- a/cli/src/artifacts.ts +++ b/cli/src/artifacts.ts @@ -6,6 +6,7 @@ import { fdir } from 'fdir' import { getNapiConfig } from './consts' import { debugFactory } from './debug' +import { UniArchsByPlatform } from './parse-triple' import { readFileAsync, writeFileAsync } from './utils' const debug = debugFactory('artifacts') @@ -38,6 +39,14 @@ export class ArtifactsCommand extends Command { join(process.cwd(), this.distDir, platform.platformArchABI), ) + const universalSourceBins = new Set( + platforms + .filter((platform) => platform.arch === 'universal') + .flatMap((p) => + UniArchsByPlatform[p.platform].map((a) => `${p.platform}-${a}`), + ), + ) + await sourceApi.withPromise().then((output) => Promise.all( (output as string[]).map(async (filePath) => { @@ -53,6 +62,14 @@ export class ArtifactsCommand extends Command { ) } const dir = distDirs.find((dir) => dir.includes(platformArchABI)) + if (!dir && universalSourceBins.has(platformArchABI)) { + debug( + `[${chalk.yellowBright( + platformArchABI, + )}] has no dist dir but it is source bin for universal arch, skip`, + ) + return + } if (!dir) { throw new TypeError(`No dist dir found for ${filePath}`) }