fix(workdir): handle directory change errors gracefully

This commit is contained in:
Naoki Oketani
2025-05-05 12:09:35 +00:00
parent b1bbd22155
commit b91c65bee2
3 changed files with 29 additions and 3 deletions

12
dist/index.js generated vendored
View File

@@ -34552,7 +34552,17 @@ async function run() {
if (!isValid(normalizedWorkingDirectory)) {
throw new Error('Invalid input: working_directory');
}
process.chdir(normalizedWorkingDirectory);
try {
// Try to change directory
process.chdir(normalizedWorkingDirectory);
coreExports.info(`Successfully changed directory to: ${normalizedWorkingDirectory}`);
}
catch (error) {
// If changing directory fails, log the error but continue
coreExports.warning(`Failed to change directory to: ${normalizedWorkingDirectory}`);
coreExports.warning(`Error: ${error instanceof Error ? error.message : String(error)}`);
coreExports.warning('Continuing with current directory');
}
}
coreExports.info(`Current working directory: ${process.cwd()}`);
// get audit-level

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -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()}`)