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';
 | 
					const COLOR_TOOLBAR = process.env.ICON_COLOR_TOOLBAR || '#111827';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ensureMagick() {
 | 
					function ensureMagick() {
 | 
				
			||||||
  const which = spawnSync('bash', ['-lc', 'command -v magick || command -v convert']);
 | 
					  // Prefer calling binaries directly to avoid shell init output polluting stdout.
 | 
				
			||||||
  if (which.status !== 0) return null;
 | 
					  let ok = spawnSync('magick', ['-version']);
 | 
				
			||||||
  const bin = which.stdout.toString().trim();
 | 
					  if (ok && ok.status === 0) return 'magick';
 | 
				
			||||||
  return bin || null;
 | 
					  ok = spawnSync('convert', ['-version']);
 | 
				
			||||||
 | 
					  if (ok && ok.status === 0) return 'convert';
 | 
				
			||||||
 | 
					  return null;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function readSvg() {
 | 
					function readSvg() {
 | 
				
			||||||
| 
						 | 
					@ -46,10 +48,8 @@ function colorize(svg, color) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function rasterize(magickBin, svgString, size, outPath) {
 | 
					function rasterize(magickBin, svgString, size, outPath) {
 | 
				
			||||||
  // Use ImageMagick, transparent background, high density for crisp vector rasterization.
 | 
					  // 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}`], {
 | 
					  const args = ['-background', 'none', '-density', '384', 'svg:-', '-resize', `${size}x${size}`, outPath];
 | 
				
			||||||
    input: svgString,
 | 
					  const proc = spawnSync(magickBin, args, { input: svgString, stdio: ['pipe', 'inherit', 'inherit'] });
 | 
				
			||||||
    stdio: ['pipe', 'inherit', 'inherit'],
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
  if (proc.status !== 0) {
 | 
					  if (proc.status !== 0) {
 | 
				
			||||||
    console.error(`Failed to generate ${outPath}`);
 | 
					    console.error(`Failed to generate ${outPath}`);
 | 
				
			||||||
    process.exit(proc.status || 1);
 | 
					    process.exit(proc.status || 1);
 | 
				
			||||||
| 
						 | 
					@ -84,4 +84,3 @@ function main() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
main();
 | 
					main();
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue