yamadashy--repomix
719032b19f
Update Schema / Update configuration json schema (push) Has been cancelled
Memory Benchmark / Memory Test (Full Analysis) (push) Has been cancelled
CI Quality / Lint GitHub Actions (actionlint) (push) Has been cancelled
CI Quality / Lint GitHub Actions (zizmor) (push) Has been cancelled
CI Quality / Check typos (push) Has been cancelled
CI / Test coverage (push) Has been cancelled
CI / Test (22.x, windows-latest) (push) Has been cancelled
CI / Test (24.x, macos-latest) (push) Has been cancelled
CI / Test (24.x, ubuntu-latest) (push) Has been cancelled
CI / Test (24.x, windows-latest) (push) Has been cancelled
CI / Test (26.x, macos-latest) (push) Has been cancelled
CI / Test (26.x, ubuntu-latest) (push) Has been cancelled
CI / Test (26.x, windows-latest) (push) Has been cancelled
CI / Test with Bun (latest, macos-latest) (push) Has been cancelled
CI / Test with Bun (latest, ubuntu-latest) (push) Has been cancelled
CI / Test with Bun (latest, windows-latest) (push) Has been cancelled
CI / Build and run (22.x, macos-latest) (push) Has been cancelled
CI / Build and run (22.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (22.x, windows-latest) (push) Has been cancelled
autofix.ci / autofix (push) Has been cancelled
CI Browser Extension / Lint Browser Extension (push) Has been cancelled
CI Browser Extension / Test Browser Extension (push) Has been cancelled
Memory Benchmark / Memory Test (push) Has been cancelled
CI Website / Lint Website Client (push) Has been cancelled
CI Website / Lint Website Server (push) Has been cancelled
CI Website / Test Website Server (push) Has been cancelled
CI Website / Bundle Website Server (push) Has been cancelled
CI / Lint Biome (push) Has been cancelled
CI / Lint oxlint (push) Has been cancelled
CI / Lint TypeScript (push) Has been cancelled
CI / Lint Secretlint (push) Has been cancelled
CI / Test (22.x, macos-latest) (push) Has been cancelled
CI / Test (22.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (24.x, macos-latest) (push) Has been cancelled
CI / Build and run (24.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (24.x, windows-latest) (push) Has been cancelled
CI / Build and run (26.x, macos-latest) (push) Has been cancelled
CI / Build and run (26.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (26.x, windows-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, macos-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, ubuntu-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Docker / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Docker / build (linux/arm/v7, ubuntu-24.04-arm) (push) Has been cancelled
Docker / build (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Docker / merge (push) Has been cancelled
Pack repository with Repomix / pack-repo (push) Has been cancelled
Performance Benchmark History / Benchmark (macos-latest) (push) Has been cancelled
Performance Benchmark History / Benchmark (ubuntu-latest) (push) Has been cancelled
Performance Benchmark History / Benchmark (windows-latest) (push) Has been cancelled
Performance Benchmark History / Store Results (push) Has been cancelled
Test Repomix Action / Test Node.js 22 (push) Has been cancelled
Test Repomix Action / Test Node.js 24 (push) Has been cancelled
Test Repomix Action / Test Node.js 26 (push) Has been cancelled
88 行
3.1 KiB
TypeScript
88 行
3.1 KiB
TypeScript
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
import { getGlobalDirectory } from '../../src/config/globalDirectory.js';
|
|
|
|
vi.mock('node:os');
|
|
|
|
describe('getGlobalDirectory', () => {
|
|
const originalPlatform = process.platform;
|
|
const originalEnv = process.env;
|
|
|
|
beforeEach(() => {
|
|
vi.resetAllMocks();
|
|
process.env = { ...originalEnv };
|
|
});
|
|
|
|
afterEach(() => {
|
|
Object.defineProperty(process, 'platform', { value: originalPlatform });
|
|
process.env = originalEnv;
|
|
});
|
|
|
|
describe('Windows platform', () => {
|
|
test('should use LOCALAPPDATA when available', () => {
|
|
Object.defineProperty(process, 'platform', { value: 'win32' });
|
|
process.env.LOCALAPPDATA = 'C:\\Users\\Test\\AppData\\Local';
|
|
|
|
const result = getGlobalDirectory();
|
|
expect(result).toBe(path.join('C:\\Users\\Test\\AppData\\Local', 'Repomix'));
|
|
});
|
|
|
|
test('should fall back to homedir when LOCALAPPDATA is not available', () => {
|
|
Object.defineProperty(process, 'platform', { value: 'win32' });
|
|
process.env.LOCALAPPDATA = undefined;
|
|
vi.mocked(os.homedir).mockReturnValue('C:\\Users\\Test');
|
|
|
|
const result = getGlobalDirectory();
|
|
expect(result).toBe(path.join('C:\\Users\\Test', 'AppData', 'Local', 'Repomix'));
|
|
});
|
|
});
|
|
|
|
describe('Unix platforms', () => {
|
|
test('should use XDG_CONFIG_HOME when available', () => {
|
|
Object.defineProperty(process, 'platform', { value: 'linux' });
|
|
process.env.XDG_CONFIG_HOME = '/custom/config';
|
|
|
|
const result = getGlobalDirectory();
|
|
expect(result).toBe(path.join('/custom/config', 'repomix'));
|
|
});
|
|
|
|
test('should fall back to ~/.config on Linux', () => {
|
|
Object.defineProperty(process, 'platform', { value: 'linux' });
|
|
process.env.XDG_CONFIG_HOME = undefined;
|
|
vi.mocked(os.homedir).mockReturnValue('/home/test');
|
|
|
|
const result = getGlobalDirectory();
|
|
expect(result).toBe(path.join('/home/test', '.config', 'repomix'));
|
|
});
|
|
|
|
test('should fall back to ~/.config on macOS', () => {
|
|
Object.defineProperty(process, 'platform', { value: 'darwin' });
|
|
process.env.XDG_CONFIG_HOME = undefined;
|
|
vi.mocked(os.homedir).mockReturnValue('/Users/test');
|
|
|
|
const result = getGlobalDirectory();
|
|
expect(result).toBe(path.join('/Users/test', '.config', 'repomix'));
|
|
});
|
|
});
|
|
|
|
describe('Edge cases', () => {
|
|
test('should handle empty homedir', () => {
|
|
Object.defineProperty(process, 'platform', { value: 'linux' });
|
|
process.env.XDG_CONFIG_HOME = undefined;
|
|
vi.mocked(os.homedir).mockReturnValue('');
|
|
|
|
const result = getGlobalDirectory();
|
|
expect(result).toBe(path.join('', '.config', 'repomix'));
|
|
});
|
|
|
|
test('should handle unusual XDG_CONFIG_HOME paths', () => {
|
|
Object.defineProperty(process, 'platform', { value: 'linux' });
|
|
process.env.XDG_CONFIG_HOME = '////multiple///slashes///';
|
|
|
|
const result = getGlobalDirectory();
|
|
expect(result).toBe(path.join('////multiple///slashes///', 'repomix'));
|
|
});
|
|
});
|
|
});
|