Skip to content

Commit e0d8939

Browse files
committed
Address more CI issues
1 parent 059abf4 commit e0d8939

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

claude-config-composer/src/cli/commands/generate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ export class GenerateCommand {
196196
*/
197197
private static async isClaudeConfigRepo(): Promise<boolean> {
198198
try {
199-
const packageJson = await fs.readFile(path.join(process.cwd(), 'package.json'), 'utf-8');
199+
// Use relative path to avoid process.cwd() issues in CI
200+
const packageJson = await fs.readFile('package.json', 'utf-8');
200201
const pkg = JSON.parse(packageJson);
201202
return pkg.name === 'claude-config-composer';
202203
} catch {

claude-config-composer/src/cli/utils/backup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export class BackupUtils {
4545
return ErrorHandler.wrapAsync(
4646
async () => {
4747
try {
48-
const gitignorePath = path.join(process.cwd(), '.gitignore');
48+
// Use relative path to avoid process.cwd() issues in CI
49+
const gitignorePath = '.gitignore';
4950
let gitignoreContent = '';
5051

5152
try {

claude-config-composer/src/generator/config-generator.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ export class ConfigGenerator {
3232
showProgress: boolean = true
3333
): Promise<void> {
3434
// Handle output directory path
35-
// For absolute paths (like temp directories in tests), use directly
36-
// For relative paths, just resolve them
37-
if (path.isAbsolute(outputDir)) {
38-
// For absolute paths (e.g., temp directories in CI), use as-is
39-
outputDir = path.normalize(outputDir);
40-
} else {
41-
// For relative paths, resolve from current directory
42-
// Don't use sanitizePath here as it rejects valid paths
43-
outputDir = path.resolve(process.cwd(), outputDir || '.');
35+
// Always normalize the path, whether absolute or relative
36+
// This avoids the need for process.cwd() which can fail in CI
37+
if (!outputDir) {
38+
outputDir = '.';
4439
}
40+
41+
// Normalize the path - this works for both absolute and relative paths
42+
// and doesn't require process.cwd()
43+
outputDir = path.normalize(outputDir);
4544

4645
// Validate input configurations
4746
try {

claude-config-composer/src/utils/path-validator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ export class PathValidator {
231231
* Safely creates a directory path, ensuring it's within the allowed base path
232232
*/
233233
static async createSafeDirectory(targetPath: string, basePath: string): Promise<string> {
234-
// Handle current directory case
235-
const effectiveBasePath = basePath === '.' ? process.cwd() : basePath;
234+
// Handle current directory case - just use the provided basePath
235+
// Avoid process.cwd() which can fail in CI when directory is deleted
236+
const effectiveBasePath = basePath || '.';
236237

237238
const validatedPath = PathValidator.validatePath(targetPath, effectiveBasePath);
238239
const fullPath = path.join(effectiveBasePath, validatedPath);

0 commit comments

Comments
 (0)