From 14281a1bf5ba6f5d8068c03d956901df539b5062 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 12 Feb 2026 07:51:51 -0800 Subject: [PATCH] don't diff binary files --- src/cli/commands/sync.ts | 45 +++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/cli/commands/sync.ts b/src/cli/commands/sync.ts index 0e46a9b..09cca36 100644 --- a/src/cli/commands/sync.ts +++ b/src/cli/commands/sync.ts @@ -397,14 +397,23 @@ export async function diffApp() { console.log(color.gray('─'.repeat(60))) } - // Fetch all changed files in parallel + // Fetch all changed files in parallel (skip binary files) const remoteContents = await Promise.all( - changed.map(file => download(`/api/sync/apps/${appName}/files/${file}`)) + changed.map(file => isBinary(file) ? null : download(`/api/sync/apps/${appName}/files/${file}`)) ) // Show diffs for changed files for (let i = 0; i < changed.length; i++) { const file = changed[i]! + + console.log(color.bold(`\n${file}`)) + console.log(color.gray('─'.repeat(60))) + + if (isBinary(file)) { + console.log(color.gray('Binary file changed')) + continue + } + const remoteContent = remoteContents[i] const localContent = readFileSync(join(process.cwd(), file), 'utf-8') @@ -414,9 +423,6 @@ export async function diffApp() { } const remoteText = new TextDecoder().decode(remoteContent) - - console.log(color.bold(`\n${file}`)) - console.log(color.gray('─'.repeat(60))) showDiff(remoteText, localContent) } @@ -425,6 +431,12 @@ export async function diffApp() { console.log(color.green('\nNew file (local only)')) console.log(color.bold(`${file}`)) console.log(color.gray('─'.repeat(60))) + + if (isBinary(file)) { + console.log(color.gray('Binary file')) + continue + } + const content = readFileSync(join(process.cwd(), file), 'utf-8') const lines = content.split('\n') for (let i = 0; i < Math.min(lines.length, 10); i++) { @@ -435,9 +447,9 @@ export async function diffApp() { } } - // Fetch all remote-only files in parallel + // Fetch all remote-only files in parallel (skip binary files) const remoteOnlyContents = await Promise.all( - remoteOnly.map(file => download(`/api/sync/apps/${appName}/files/${file}`)) + remoteOnly.map(file => isBinary(file) ? null : download(`/api/sync/apps/${appName}/files/${file}`)) ) // Show remote-only files @@ -448,6 +460,12 @@ export async function diffApp() { console.log(color.bold(`\n${file}`)) console.log(color.gray('─'.repeat(60))) console.log(color.red('Remote only')) + + if (isBinary(file)) { + console.log(color.gray('Binary file')) + continue + } + if (content) { const text = new TextDecoder().decode(content) const lines = text.split('\n') @@ -1087,6 +1105,19 @@ async function getManifestDiff(appName: string): Promise { } } +const BINARY_EXTENSIONS = new Set([ + '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.ico', '.webp', '.avif', '.heic', '.tiff', + '.woff', '.woff2', '.ttf', '.eot', '.otf', + '.mp3', '.mp4', '.wav', '.ogg', '.webm', '.avi', '.mov', + '.pdf', '.zip', '.tar', '.gz', '.br', '.zst', + '.wasm', '.exe', '.dll', '.so', '.dylib', +]) + +const isBinary = (filename: string) => { + const ext = filename.slice(filename.lastIndexOf('.')).toLowerCase() + return BINARY_EXTENSIONS.has(ext) +} + function showDiff(remote: string, local: string) { const changes = diffLines(remote, local) let lineCount = 0