fix(build): call ImageMagick directly to avoid shell banner output breaking icon generation
This commit is contained in:
		
					parent
					
						
							
								e6557513f7
							
						
					
				
			
			
				commit
				
					
						164dfdfb93
					
				
			
		
					 1 changed files with 8 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -25,10 +25,12 @@ const COLOR_ADDON = process.env.ICON_COLOR_ADDON || '#111827';
 | 
			
		|||
const COLOR_TOOLBAR = process.env.ICON_COLOR_TOOLBAR || '#111827';
 | 
			
		||||
 | 
			
		||||
function ensureMagick() {
 | 
			
		||||
  const which = spawnSync('bash', ['-lc', 'command -v magick || command -v convert']);
 | 
			
		||||
  if (which.status !== 0) return null;
 | 
			
		||||
  const bin = which.stdout.toString().trim();
 | 
			
		||||
  return bin || null;
 | 
			
		||||
  // Prefer calling binaries directly to avoid shell init output polluting stdout.
 | 
			
		||||
  let ok = spawnSync('magick', ['-version']);
 | 
			
		||||
  if (ok && ok.status === 0) return 'magick';
 | 
			
		||||
  ok = spawnSync('convert', ['-version']);
 | 
			
		||||
  if (ok && ok.status === 0) return 'convert';
 | 
			
		||||
  return null;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function readSvg() {
 | 
			
		||||
| 
						 | 
				
			
			@ -46,10 +48,8 @@ function colorize(svg, color) {
 | 
			
		|||
 | 
			
		||||
function rasterize(magickBin, svgString, size, outPath) {
 | 
			
		||||
  // Use ImageMagick, transparent background, high density for crisp vector rasterization.
 | 
			
		||||
  const proc = spawnSync('bash', ['-lc', `${magickBin} -background none -density 384 svg:- -resize ${size}x${size} ${outPath}`], {
 | 
			
		||||
    input: svgString,
 | 
			
		||||
    stdio: ['pipe', 'inherit', 'inherit'],
 | 
			
		||||
  });
 | 
			
		||||
  const args = ['-background', 'none', '-density', '384', 'svg:-', '-resize', `${size}x${size}`, outPath];
 | 
			
		||||
  const proc = spawnSync(magickBin, args, { input: svgString, stdio: ['pipe', 'inherit', 'inherit'] });
 | 
			
		||||
  if (proc.status !== 0) {
 | 
			
		||||
    console.error(`Failed to generate ${outPath}`);
 | 
			
		||||
    process.exit(proc.status || 1);
 | 
			
		||||
| 
						 | 
				
			
			@ -84,4 +84,3 @@ function main() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
main();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue