fix(workdir): handle trailing slash in working directory path

This commit is contained in:
Naoki Oketani
2025-05-05 12:03:14 +00:00
parent db3cc003b1
commit 0ff4c383ef
3 changed files with 14 additions and 5 deletions

8
dist/index.js generated vendored
View File

@@ -34545,10 +34545,14 @@ async function run() {
// move to working directory
const workingDirectory = coreExports.getInput('working_directory');
if (workingDirectory) {
if (!isValid(workingDirectory)) {
// Remove trailing slash if present
const normalizedWorkingDirectory = workingDirectory.endsWith('/')
? workingDirectory.slice(0, -1)
: workingDirectory;
if (!isValid(normalizedWorkingDirectory)) {
throw new Error('Invalid input: working_directory');
}
process.chdir(workingDirectory);
process.chdir(normalizedWorkingDirectory);
}
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

@@ -12,10 +12,15 @@ export async function run(): Promise<void> {
// move to working directory
const workingDirectory = core.getInput('working_directory')
if (workingDirectory) {
if (!workdir.isValid(workingDirectory)) {
// Remove trailing slash if present
const normalizedWorkingDirectory = workingDirectory.endsWith('/')
? workingDirectory.slice(0, -1)
: workingDirectory
if (!workdir.isValid(normalizedWorkingDirectory)) {
throw new Error('Invalid input: working_directory')
}
process.chdir(workingDirectory)
process.chdir(normalizedWorkingDirectory)
}
core.info(`Current working directory: ${process.cwd()}`)