feat(build): implement artifact names

This commit is contained in:
2026-07-29 21:52:46 +02:00
parent 4062eb4e82
commit 9a76acafc0
+8 -3
View File
@@ -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);
}
};