fix(workdir): handle directory change errors gracefully
This commit is contained in:
18
src/main.ts
18
src/main.ts
@@ -20,7 +20,23 @@ export async function run(): Promise<void> {
|
||||
if (!workdir.isValid(normalizedWorkingDirectory)) {
|
||||
throw new Error('Invalid input: working_directory')
|
||||
}
|
||||
process.chdir(normalizedWorkingDirectory)
|
||||
|
||||
try {
|
||||
// Try to change directory
|
||||
process.chdir(normalizedWorkingDirectory)
|
||||
core.info(
|
||||
`Successfully changed directory to: ${normalizedWorkingDirectory}`
|
||||
)
|
||||
} catch (error) {
|
||||
// If changing directory fails, log the error but continue
|
||||
core.warning(
|
||||
`Failed to change directory to: ${normalizedWorkingDirectory}`
|
||||
)
|
||||
core.warning(
|
||||
`Error: ${error instanceof Error ? error.message : String(error)}`
|
||||
)
|
||||
core.warning('Continuing with current directory')
|
||||
}
|
||||
}
|
||||
core.info(`Current working directory: ${process.cwd()}`)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user