From 4a3010b68392401a66438bfbdfcb6a82a77197ae Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Wed, 29 Jul 2026 21:35:59 +0200 Subject: [PATCH] feat(build): implement artifact names --- build/utils/artifact.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build/utils/artifact.js b/build/utils/artifact.js index 8187de3..0afca46 100644 --- a/build/utils/artifact.js +++ b/build/utils/artifact.js @@ -18,6 +18,11 @@ import { exists, isDirectory } from './fileAccess.js'; import { cp, mkdir, writeFile } from 'node:fs/promises'; import { dirname, join } from 'node:path'; +const logWithName = function logWithName (message, name, loggingFunction = console.log) { + if (name) loggingFunction(`Artifact '${name}': ${message}`); + else loggingFunction(message); +}; + const validateArtifact = function validateArtifact (artifact) { if (typeof artifact.path !== 'string') return false; if (artifact.type === 'text') { @@ -39,7 +44,7 @@ const validateArtifact = function validateArtifact (artifact) { export const processArtifact = async function processArtifact (artifact, { srcBase = '.', distBase = '.' } = {}) { if (!validateArtifact(artifact)) { - console.warn('Skipping artifact as it is invalid.'); + logWithName('Skipping artifact as it is invalid.', artifact.name, console.warn); return; } const distPath = join(distBase, artifact.path); @@ -55,7 +60,7 @@ export const processArtifact = async function processArtifact (artifact, { srcBa encoding: artifact.options.encoding ?? 'utf-8' } ); - console.log(`Wrote to ${distPath}`); + logWithName(`Wrote to ${distPath}`, artifact.name); } else if (artifact.type === 'copy') { const srcPath = join( srcBase, @@ -71,6 +76,6 @@ export const processArtifact = async function processArtifact (artifact, { srcBa force: true } ); - console.log(`Copied ${srcPath} -> ${distPath}`); + logWithName(`Copied ${srcPath} -> ${distPath}`, artifact.name); } }; \ No newline at end of file