File tree Expand file tree Collapse file tree 7 files changed +16
-39
lines changed Expand file tree Collapse file tree 7 files changed +16
-39
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default class OpenAPIConvertCommand extends BaseCommand<typeof OpenAPICon
2828 static flags = {
2929 out : Flags . string ( { description : 'Output file path to write converted file to' } ) ,
3030 title : titleFlag ,
31- workingDirectory : workingDirectoryFlag ,
31+ 'working-directory' : workingDirectoryFlag ,
3232 } ;
3333
3434 static examples = [
@@ -45,13 +45,7 @@ export default class OpenAPIConvertCommand extends BaseCommand<typeof OpenAPICon
4545 ] ;
4646
4747 async run ( ) {
48- const { out, workingDirectory } = this . flags ;
49-
50- if ( workingDirectory ) {
51- const previousWorkingDirectory = process . cwd ( ) ;
52- process . chdir ( workingDirectory ) ;
53- this . debug ( `switching working directory from ${ previousWorkingDirectory } to ${ process . cwd ( ) } ` ) ;
54- }
48+ const { out } = this . flags ;
5549
5650 const { preparedSpec, specPath, specType } = await prepareOas . call ( this ) ;
5751 const parsedPreparedSpec : OASDocument = JSON . parse ( preparedSpec ) ;
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ export default class OpenAPIInspectCommand extends BaseCommand<typeof OpenAPIIns
216216 multiple : true ,
217217 options : getSupportedFeatures ( ) ,
218218 } ) ,
219- workingDirectory : workingDirectoryFlag ,
219+ 'working-directory' : workingDirectoryFlag ,
220220 } ;
221221
222222 static examples = [
@@ -239,19 +239,13 @@ export default class OpenAPIInspectCommand extends BaseCommand<typeof OpenAPIIns
239239 ] ;
240240
241241 async run ( ) {
242- const { workingDirectory , feature : features } = this . flags ;
242+ const { feature : features } = this . flags ;
243243
244244 const tableBorder = Object . entries ( getBorderCharacters ( 'norc' ) )
245245 . map ( ( [ border , char ] ) => ( { [ border ] : chalk . gray ( char ) } ) )
246246 // biome-ignore lint/performance/noAccumulatingSpread: @todo can this be improved?
247247 . reduce ( ( prev , next ) => Object . assign ( prev , next ) ) ;
248248
249- if ( workingDirectory ) {
250- const previousWorkingDirectory = process . cwd ( ) ;
251- process . chdir ( workingDirectory ) ;
252- this . debug ( `switching working directory from ${ previousWorkingDirectory } to ${ process . cwd ( ) } ` ) ;
253- }
254-
255249 const { preparedSpec, definitionVersion } = await prepareOas . call ( this ) ;
256250 const parsedPreparedSpec : OASDocument = JSON . parse ( preparedSpec ) ;
257251
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export default class OpenAPIReduceCommand extends BaseCommand<typeof OpenAPIRedu
3838 path : Flags . string ( { description : 'Paths to reduce by' , multiple : true } ) ,
3939 tag : Flags . string ( { description : 'Tags to reduce by' , multiple : true } ) ,
4040 title : titleFlag ,
41- workingDirectory : workingDirectoryFlag ,
41+ 'working-directory' : workingDirectoryFlag ,
4242 } ;
4343
4444 static examples = [
@@ -61,13 +61,6 @@ export default class OpenAPIReduceCommand extends BaseCommand<typeof OpenAPIRedu
6161
6262 async run ( ) {
6363 const opts = this . flags ;
64- const { workingDirectory } = opts ;
65-
66- if ( workingDirectory ) {
67- const previousWorkingDirectory = process . cwd ( ) ;
68- process . chdir ( workingDirectory ) ;
69- this . debug ( `switching working directory from ${ previousWorkingDirectory } to ${ process . cwd ( ) } ` ) ;
70- }
7164
7265 const { preparedSpec, specPath, specType } = await prepareOas . call ( this ) ;
7366 const parsedPreparedSpec : OASDocument = JSON . parse ( preparedSpec ) ;
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ export default class OpenAPIResolveCommand extends BaseCommand<typeof OpenAPIRes
5353 static flags = {
5454 out : Flags . string ( { description : 'Output file path to write resolved file to' } ) ,
5555 title : titleFlag ,
56- workingDirectory : workingDirectoryFlag ,
56+ 'working-directory' : workingDirectoryFlag ,
5757 } ;
5858
5959 /**
@@ -345,13 +345,7 @@ export default class OpenAPIResolveCommand extends BaseCommand<typeof OpenAPIRes
345345 }
346346
347347 async run ( ) {
348- const { out, workingDirectory } = this . flags ;
349-
350- if ( workingDirectory ) {
351- const previousWorkingDirectory = process . cwd ( ) ;
352- process . chdir ( workingDirectory ) ;
353- this . debug ( `Switching working directory from ${ previousWorkingDirectory } to ${ process . cwd ( ) } ` ) ;
354- }
348+ const { out } = this . flags ;
355349
356350 const { preparedSpec, specPath, specType } = await prepareOas . call ( this ) ;
357351 if ( specType !== 'OpenAPI' ) {
Original file line number Diff line number Diff line change @@ -33,16 +33,10 @@ export default class OpenAPIValidateCommand extends BaseCommand<typeof OpenAPIVa
3333
3434 static flags = {
3535 github : githubFlag ,
36- workingDirectory : workingDirectoryFlag ,
36+ 'working-directory' : workingDirectoryFlag ,
3737 } ;
3838
3939 async run ( ) {
40- if ( this . flags . workingDirectory ) {
41- const previousWorkingDirectory = process . cwd ( ) ;
42- process . chdir ( this . flags . workingDirectory ) ;
43- this . debug ( `switching working directory from ${ previousWorkingDirectory } to ${ process . cwd ( ) } ` ) ;
44- }
45-
4640 const { specPath, specType } = await prepareOas . call ( this ) ;
4741
4842 return this . runCreateGHAHook ( {
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ export const titleFlag = Flags.string({
4646 * Used in the `openapi` family of commands where `workingDirectory` is an option.
4747 */
4848export const workingDirectoryFlag = Flags . string ( {
49+ aliases : [ 'workingDirectory' ] ,
50+ deprecateAliases : true ,
4951 description : 'Working directory (for usage with relative external references)' ,
5052} ) ;
5153
Original file line number Diff line number Diff line change @@ -53,6 +53,12 @@ export default async function prepareOas(this: OpenAPICommands) {
5353 let specPath = this . args . spec ;
5454 const command = this . id satisfies `openapi ${OpenAPIAction } `;
5555
56+ if ( this . flags . workingDirectory ) {
57+ const previousWorkingDirectory = process . cwd ( ) ;
58+ process . chdir ( this . flags . workingDirectory ) ;
59+ this . debug ( `switching working directory from ${ previousWorkingDirectory } to ${ process . cwd ( ) } ` ) ;
60+ }
61+
5662 if ( ! specPath ) {
5763 /**
5864 * Scans working directory for a potential OpenAPI or Swagger file.
You can’t perform that action at this time.
0 commit comments