fix(workdir): handle directory change errors gracefully
This commit is contained in:
12
dist/index.js
generated
vendored
12
dist/index.js
generated
vendored
@@ -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
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
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