#!/bin/sh
node <<'EOF'
import { lilconfig, lilconfigSync } from 'lilconfig';
import { writeFileSync, mkdtempSync, rmSync } from 'fs';
import { join } from 'path';
import os from 'os';

// Create a temp directory with a config file
const tmp = mkdtempSync(join(os.tmpdir(), 'lilconfig-test-'));
const configPath = join(tmp, 'myapp.conf.js');

writeFileSync(
  configPath,
  `module.exports = { value: 42 };`,
  'utf8'
);

// Options (all optional)
const options = {
  stopDir: tmp,
  searchPlaces: ['myapp.conf.js'],
  ignoreEmptySearchPlaces: false
};

// --- Sync test ---
const syncResult = lilconfigSync('myapp', options).load(configPath);
console.log('SYNC RESULT:', syncResult);

// --- Async test ---
(async () => {
  const asyncResult = await lilconfig('myapp', options).search();
  console.log('ASYNC RESULT:', asyncResult);
  rmSync(tmp, { recursive: true, force: true })
})();
EOF