import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { fileURLToPath } from 'node:url';

const here = path.dirname(fileURLToPath(import.meta.url));

void test('main: EPIPE guards ставятся до app.whenReady', () => {
  const index = fs.readFileSync(path.join(here, 'index.ts'), 'utf8');
  const safe = fs.readFileSync(path.join(here, 'safeConsole.ts'), 'utf8');
  assert.ok(index.includes('installStdoutEpipeGuards'));
  assert.ok(index.indexOf('installStdoutEpipeGuards()') < index.indexOf('app.requestSingleInstanceLock'));
  assert.ok(safe.includes('EPIPE'));
  assert.ok(safe.includes('safeConsoleError'));
});
