Skip to content

Commit e64e3df

Browse files
fix: ensure correct path resolution in CLI setup (#553)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 390fda9 commit e64e3df

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@effect/language-service": patch
3+
---
4+
5+
fix: ensure correct path resolution in CLI setup
6+
7+
- Use `process.cwd()` explicitly in `path.resolve()` for consistent behavior
8+
- Resolve the selected tsconfig path to an absolute path before validation
9+
- Simplify error handling by using direct `yield*` for `TsConfigNotFoundError`

src/cli/setup.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ const createAssessmentInput = (
3535
const packageJsonExists = yield* fs.exists(packageJsonPath)
3636

3737
if (!packageJsonExists) {
38-
return yield* Effect.fail(
39-
new PackageJsonNotFoundError({ path: packageJsonPath })
40-
)
38+
return yield* new PackageJsonNotFoundError({ path: packageJsonPath })
4139
}
4240

4341
const packageJsonText = yield* fs.readFileString(packageJsonPath).pipe(
@@ -83,7 +81,7 @@ export const setup = Command.make(
8381
// ========================================================================
8482
// Phase 1: Select tsconfig file
8583
// ========================================================================
86-
const currentDir = path.resolve(".")
84+
const currentDir = path.resolve(process.cwd())
8785
const tsconfigInput = yield* selectTsConfigFile(currentDir)
8886

8987
// ========================================================================

src/cli/setup/tsconfig-prompt.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const selectTsConfigFile = (
3939
> =>
4040
Effect.gen(function*() {
4141
const fs = yield* FileSystem.FileSystem
42+
const path = yield* Path.Path
4243

4344
const tsconfigFiles = yield* findTsConfigFiles(currentDir)
4445

@@ -75,13 +76,12 @@ export const selectTsConfigFile = (
7576
selectedTsconfigPath = selected
7677
}
7778
}
79+
selectedTsconfigPath = path.resolve(selectedTsconfigPath)
7880

7981
// Check if the selected tsconfig file exists
8082
const tsconfigExists = yield* fs.exists(selectedTsconfigPath)
8183
if (!tsconfigExists) {
82-
return yield* Effect.fail(
83-
new TsConfigNotFoundError({ path: selectedTsconfigPath })
84-
)
84+
return yield* new TsConfigNotFoundError({ path: selectedTsconfigPath })
8585
}
8686

8787
// Read the tsconfig file

0 commit comments

Comments
 (0)