chore: apply requested changes

This commit is contained in:
Ralph Khreish
2025-11-20 19:03:42 +01:00
parent 32bb968244
commit 6ac38dbf39
5 changed files with 30 additions and 12 deletions

View File

@@ -18,6 +18,9 @@ import {
} from '../../fixtures/task-fixtures';
import { getCliBinPath } from '../../helpers/test-utils';
// Capture initial working directory at module load time
const initialCwd = process.cwd();
describe('list command', () => {
let testDir: string;
let tasksPath: string;
@@ -44,9 +47,10 @@ describe('list command', () => {
afterEach(() => {
try {
const originalDir = path.resolve(__dirname, '../../../../..');
process.chdir(originalDir);
// Restore to the original working directory captured at module load
process.chdir(initialCwd);
} catch {
// Fallback to home directory if initial directory no longer exists
process.chdir(os.homedir());
}

View File

@@ -14,6 +14,9 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { createTask, createTasksFile } from '../../fixtures/task-fixtures';
import { getCliBinPath } from '../../helpers/test-utils';
// Capture initial working directory at module load time
const initialCwd = process.cwd();
describe('next command', () => {
let testDir: string;
let tasksPath: string;
@@ -40,9 +43,10 @@ describe('next command', () => {
afterEach(() => {
try {
const originalDir = path.resolve(__dirname, '../../../../..');
process.chdir(originalDir);
// Restore to the original working directory captured at module load
process.chdir(initialCwd);
} catch {
// Fallback to home directory if initial directory no longer exists
process.chdir(os.homedir());
}

View File

@@ -15,6 +15,9 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { createTask, createTasksFile } from '../../fixtures/task-fixtures';
import { getCliBinPath } from '../../helpers/test-utils';
// Capture initial working directory at module load time
const initialCwd = process.cwd();
describe('set-status command', () => {
let testDir: string;
let tasksPath: string;
@@ -41,9 +44,10 @@ describe('set-status command', () => {
afterEach(() => {
try {
const originalDir = path.resolve(__dirname, '../../../../..');
process.chdir(originalDir);
// Restore to the original working directory captured at module load
process.chdir(initialCwd);
} catch {
// Fallback to home directory if initial directory no longer exists
process.chdir(os.homedir());
}

View File

@@ -18,6 +18,9 @@ import {
} from '../../fixtures/task-fixtures';
import { getCliBinPath } from '../../helpers/test-utils';
// Capture initial working directory at module load time
const initialCwd = process.cwd();
describe('show command', () => {
let testDir: string;
let tasksPath: string;
@@ -44,9 +47,10 @@ describe('show command', () => {
afterEach(() => {
try {
const originalDir = path.resolve(__dirname, '../../../../..');
process.chdir(originalDir);
// Restore to the original working directory captured at module load
process.chdir(initialCwd);
} catch {
// Fallback to home directory if initial directory no longer exists
process.chdir(os.homedir());
}

View File

@@ -22,6 +22,9 @@ import path from 'node:path';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { getCliBinPath } from '../helpers/test-utils';
// Capture initial working directory at module load time
const initialCwd = process.cwd();
describe('Task Lifecycle Integration Tests', () => {
let testDir: string;
let tasksPath: string;
@@ -83,11 +86,10 @@ describe('Task Lifecycle Integration Tests', () => {
*/
afterEach(() => {
try {
// Change to a safe directory before cleanup
const originalDir = path.resolve(__dirname, '../../../..');
process.chdir(originalDir);
// Restore to the original working directory captured at module load
process.chdir(initialCwd);
} catch (error) {
// Fallback to home directory if project root unavailable
// Fallback to home directory if initial directory no longer exists
process.chdir(os.homedir());
}