diff --git a/src/cmds/openapi/convert.ts b/src/cmds/openapi/convert.ts index d5d2f14ca..f57de8087 100644 --- a/src/cmds/openapi/convert.ts +++ b/src/cmds/openapi/convert.ts @@ -15,7 +15,6 @@ import { validateFilePath } from '../../lib/validatePromptInput.js'; interface Options { out?: string; spec?: string; - workingDirectory?: string; } export default class OpenAPIConvertCommand extends Command { @@ -39,20 +38,13 @@ export default class OpenAPIConvertCommand extends Command { type: String, description: 'Output file path to write converted file to', }, - this.getWorkingDirArg(), ]; } async run(opts: ZeroAuthCommandOptions) { await super.run(opts); - const { spec, workingDirectory } = opts; - - if (workingDirectory) { - const previousWorkingDirectory = process.cwd(); - process.chdir(workingDirectory); - Command.debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); - } + const { spec } = opts; const { preparedSpec, specPath, specType } = await prepareOas(spec, 'openapi:convert', { convertToLatest: true }); const parsedPreparedSpec: OASDocument = JSON.parse(preparedSpec); diff --git a/src/cmds/openapi/index.ts b/src/cmds/openapi/index.ts index 8bebe0f6b..a2c2e1c73 100644 --- a/src/cmds/openapi/index.ts +++ b/src/cmds/openapi/index.ts @@ -27,7 +27,6 @@ interface Options { update?: boolean; useSpecVersion?: boolean; version?: string; - workingDirectory?: string; } export default class OpenAPICommand extends Command { @@ -54,7 +53,6 @@ export default class OpenAPICommand extends Command { type: String, defaultOption: true, }, - this.getWorkingDirArg(), { name: 'useSpecVersion', type: Boolean, @@ -90,7 +88,7 @@ export default class OpenAPICommand extends Command { async run(opts: AuthenticatedCommandOptions) { await super.run(opts); - const { dryRun, key, id, spec, create, raw, title, useSpecVersion, version, workingDirectory, update } = opts; + const { dryRun, key, id, spec, create, raw, title, useSpecVersion, version, update } = opts; let selectedVersion = version; let isUpdate: boolean; @@ -111,12 +109,6 @@ 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) { Command.warn( "We'll be using the version associated with the `--id` option, so the `--version` option will be ignored.", diff --git a/src/cmds/openapi/inspect.ts b/src/cmds/openapi/inspect.ts index b2b6b63a2..2cc2f9685 100644 --- a/src/cmds/openapi/inspect.ts +++ b/src/cmds/openapi/inspect.ts @@ -17,7 +17,6 @@ import SoftError from '../../lib/softError.js'; interface Options { feature?: string[]; spec?: string; - workingDirectory?: string; } export default class OpenAPIInspectCommand extends Command { @@ -40,7 +39,6 @@ export default class OpenAPIInspectCommand extends Command { type: String, defaultOption: true, }, - this.getWorkingDirArg(), { name: 'feature', type: String, @@ -218,7 +216,7 @@ export default class OpenAPIInspectCommand extends Command { async run(opts: ZeroAuthCommandOptions) { await super.run(opts); - const { spec, workingDirectory, feature: features } = opts; + const { spec, feature: features } = opts; // If we have features we should validate that they're supported. if (features?.length) { @@ -232,12 +230,6 @@ 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 }); this.definitionVersion = definitionVersion.version; const parsedPreparedSpec: OASDocument = JSON.parse(preparedSpec); diff --git a/src/cmds/openapi/reduce.ts b/src/cmds/openapi/reduce.ts index 7a7a8718c..53b81a780 100644 --- a/src/cmds/openapi/reduce.ts +++ b/src/cmds/openapi/reduce.ts @@ -23,7 +23,6 @@ interface Options { spec?: string; tag?: string[]; title?: string; - workingDirectory?: string; } export default class OpenAPIReduceCommand extends Command { @@ -66,20 +65,13 @@ export default class OpenAPIReduceCommand extends Command { description: 'Output file path to write reduced file to', }, this.getTitleArg(), - this.getWorkingDirArg(), ]; } async run(opts: ZeroAuthCommandOptions) { await super.run(opts); - 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 { spec, title } = opts; const { preparedSpec, specPath, specType } = await prepareOas(spec, 'openapi:reduce', { title }); const parsedPreparedSpec: OASDocument = JSON.parse(preparedSpec); diff --git a/src/cmds/openapi/validate.ts b/src/cmds/openapi/validate.ts index 29ce5c76e..698d0d6cd 100644 --- a/src/cmds/openapi/validate.ts +++ b/src/cmds/openapi/validate.ts @@ -8,7 +8,6 @@ import prepareOas from '../../lib/prepareOas.js'; export interface Options { spec?: string; - workingDirectory?: string; } export default class OpenAPIValidateCommand extends Command { @@ -27,7 +26,6 @@ export default class OpenAPIValidateCommand extends Command { type: String, defaultOption: true, }, - this.getWorkingDirArg(), this.getGitHubArg(), ]; } @@ -35,13 +33,7 @@ export default class OpenAPIValidateCommand extends Command { async run(opts: ZeroAuthCommandOptions) { await super.run(opts); - const { spec, workingDirectory } = opts; - - if (workingDirectory) { - const previousWorkingDirectory = process.cwd(); - process.chdir(workingDirectory); - Command.debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); - } + const { spec } = opts; const { specPath, specType } = await prepareOas(spec, 'openapi:validate'); return Promise.resolve(chalk.green(`${specPath} is a valid ${specType} API definition!`)).then(msg => diff --git a/src/lib/baseCommand.ts b/src/lib/baseCommand.ts index 75bbb6f85..b0bd68b35 100644 --- a/src/lib/baseCommand.ts +++ b/src/lib/baseCommand.ts @@ -211,17 +211,6 @@ export default class Command { ]; } - /** - * Used in the `openapi` family of commands where `workingDirectory` is an option. - */ - getWorkingDirArg(): OptionDefinition { - return { - name: 'workingDirectory', - type: String, - description: 'Working directory (for usage with relative external references)', - }; - } - static debug(msg: string) { debug(msg); }