Skip to content

Commit

Permalink
chore: add debug statements for process.chdir (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta authored Aug 18, 2023
1 parent 0017967 commit 36a424a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cmds/openapi/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 2 additions & 0 deletions src/cmds/openapi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/cmds/openapi/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 2 additions & 0 deletions src/cmds/openapi/reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 2 additions & 0 deletions src/cmds/openapi/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 5 additions & 1 deletion src/lib/createGHA/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down

0 comments on commit 36a424a

Please sign in to comment.