diff --git a/src/cmds/openapi/convert.ts b/src/cmds/openapi/convert.ts index cdec36697..e2a1e81aa 100644 --- a/src/cmds/openapi/convert.ts +++ b/src/cmds/openapi/convert.ts @@ -49,7 +49,9 @@ export default class OpenAPIConvertCommand extends Command { const { spec, workingDirectory } = opts; if (workingDirectory) { + const previousWorkingDirectory = process.cwd(); process.chdir(workingDirectory); + Command.debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); } const { preparedSpec, specPath, specType } = await prepareOas(spec, 'openapi:convert', { convertToLatest: true }); diff --git a/src/cmds/openapi/index.ts b/src/cmds/openapi/index.ts index c9f632e49..bcb72d278 100644 --- a/src/cmds/openapi/index.ts +++ b/src/cmds/openapi/index.ts @@ -111,7 +111,9 @@ export default class OpenAPICommand extends Command { } if (workingDirectory) { + const previousWorkingDirectory = process.cwd(); process.chdir(workingDirectory); + Command.debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); } if (version && id) { diff --git a/src/cmds/openapi/inspect.ts b/src/cmds/openapi/inspect.ts index a2d01e0b8..47ce58dd9 100644 --- a/src/cmds/openapi/inspect.ts +++ b/src/cmds/openapi/inspect.ts @@ -235,7 +235,9 @@ export default class OpenAPIInspectCommand extends Command { } if (workingDirectory) { + const previousWorkingDirectory = process.cwd(); process.chdir(workingDirectory); + Command.debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); } const { preparedSpec, definitionVersion } = await prepareOas(spec, 'openapi:inspect', { convertToLatest: true }); diff --git a/src/cmds/openapi/reduce.ts b/src/cmds/openapi/reduce.ts index c23b2007f..67c5abe77 100644 --- a/src/cmds/openapi/reduce.ts +++ b/src/cmds/openapi/reduce.ts @@ -76,7 +76,9 @@ export default class OpenAPIReduceCommand extends Command { const { spec, title, workingDirectory } = opts; if (workingDirectory) { + const previousWorkingDirectory = process.cwd(); process.chdir(workingDirectory); + Command.debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); } const { preparedSpec, specPath, specType } = await prepareOas(spec, 'openapi:reduce', { title }); diff --git a/src/cmds/openapi/validate.ts b/src/cmds/openapi/validate.ts index a4cab5099..dcbecf22a 100644 --- a/src/cmds/openapi/validate.ts +++ b/src/cmds/openapi/validate.ts @@ -38,7 +38,9 @@ export default class OpenAPIValidateCommand extends Command { const { spec, workingDirectory } = opts; if (workingDirectory) { + const previousWorkingDirectory = process.cwd(); process.chdir(workingDirectory); + Command.debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); } const { specPath, specType } = await prepareOas(spec, 'openapi:validate'); diff --git a/src/lib/createGHA/index.ts b/src/lib/createGHA/index.ts index 2efc4791b..22905df54 100644 --- a/src/lib/createGHA/index.ts +++ b/src/lib/createGHA/index.ts @@ -209,7 +209,11 @@ export default async function createGHA( ); } - if (repoRoot) process.chdir(repoRoot); + if (repoRoot) { + const previousWorkingDirectory = process.cwd(); + process.chdir(repoRoot); + debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); + } prompts.override({ shouldCreateGHA: opts.github });