fixed cast play
This commit is contained in:
@@ -1,18 +1,37 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
const repoRoot = process.cwd();
|
||||
const binariesDir = path.join(repoRoot, 'src-tauri', 'binaries');
|
||||
|
||||
// Existing filename and expected name (Windows x86_64 triple)
|
||||
// No rename needed; ensure the sidecar exists.
|
||||
const existing = 'radiocast-sidecar-x86_64-pc-windows-msvc.exe';
|
||||
const expected = 'RadioPlayer-x86_64-pc-windows-msvc.exe';
|
||||
const expected = existing;
|
||||
|
||||
const src = path.join(binariesDir, existing);
|
||||
const dst = path.join(binariesDir, expected);
|
||||
|
||||
// On Windows the running sidecar process can lock the binary and prevent rebuilds.
|
||||
// Try to kill any leftover sidecar processes before proceeding. This is best-effort
|
||||
// and will silently continue if no process is found or the kill fails.
|
||||
function tryKillSidecar() {
|
||||
if (process.platform !== 'win32') return;
|
||||
const candidates = ['radiocast-sidecar.exe', 'radiocast-sidecar-x86_64-pc-windows-msvc.exe', 'radiocast-sidecar'];
|
||||
for (const name of candidates) {
|
||||
try {
|
||||
execSync(`taskkill /IM ${name} /F`, { stdio: 'ignore' });
|
||||
console.log(`Killed leftover sidecar process: ${name}`);
|
||||
} catch (e) {
|
||||
// ignore errors; likely means the process wasn't running
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
tryKillSidecar();
|
||||
|
||||
if (!fs.existsSync(binariesDir)) {
|
||||
console.warn('binaries directory not found, skipping copy');
|
||||
process.exit(0);
|
||||
@@ -23,14 +42,8 @@ try {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (fs.existsSync(dst)) {
|
||||
console.log(`Expected binary already present: ${dst}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
fs.copyFileSync(src, dst);
|
||||
console.log(`Copied ${existing} -> ${expected}`);
|
||||
console.log(`Sidecar binary present: ${dst}`);
|
||||
} catch (e) {
|
||||
console.error('Failed to copy binary:', e);
|
||||
console.error('Failed to prepare binary:', e);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user