INNER CODE UNIT · TypeScript

ensureHelperApp

jo-duchan/tapflow · packages/audiotap-helper/src/index.ts:54

export function ensureHelperApp(): string {
  if (existsSync(HELPER_BIN)) {
    if (!existsSync(HELPER_SRC)) return HELPER_APP // source not shipped — trust the prebuilt bundle
    if (statSync(HELPER_BIN).mtimeMs >= statSync(HELPER_SRC).mtimeMs) return HELPER_APP
    logger.info('audiotap-helper source changed, rebuilding...')
  }
  if (!existsSync(HELPER_SRC)) {
    throw new PlatformError('audiotap-helper.app missing and source not found — reinstall @tapflowio/audiotap-helper')
  }
  logger.info('building audiotap-helper.app...')
  // Build + sign as a unit. If any step fails (e.g. swiftc OK but codesign fails), remove the bundle
  // so a later call doesn't return a half-built/unsigned .app from the mtime gate above (an unsigned
  // bundle silently fails the TCC grant). Next call rebuilds from scratch.
  try {
    mkdirSync(join(HELPER_APP, 'Contents', 'MacOS'), { recursive: true })
    execFileSync('swiftc', [
      HELPER_SRC, '-o', HELPER_BIN, '-framework', 'CoreAudio', '-framework', 'AudioToolbox',
    ], { stdio: ['ignore', 'ignore', 'inherit'] })

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…