Skip to content

Commit

Permalink
fix(job-command): fixed deprecation warning for -r flag
Browse files Browse the repository at this point in the history
  • Loading branch information
YuryShkoda committed Aug 3, 2023
1 parent 8bb5887 commit dd3a6e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/commands/job/jobCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const executeParseOptions = {
alias: 'i',
default: false,
description:
'If present and return status only is provided, CLI will return status 0 when the job state is warning.'
'If present, CLI will return status 0 when the job state is warning.'
},
log: {
type: 'string',
Expand Down Expand Up @@ -114,6 +114,12 @@ export class JobCommand extends TargetCommand {
public async execute() {
const { target } = await this.getTargetInfo()

// INFO: returnStatusOnly flag is deprecated and is left to display warning if used
const returnStatusOnly = !!this.parsed.returnStatusOnly
if (returnStatusOnly) {
process.logger.warn('--returnStatusOnly (-r) flag is deprecated.')
}

// INFO: use execution function based on server type
switch (target.serverType) {
case ServerType.SasViya:
Expand Down Expand Up @@ -242,12 +248,6 @@ export class JobCommand extends TargetCommand {
? true
: false

// INFO: returnStatusOnly flag is deprecated and is left to display warning if used
const returnStatusOnly = !!this.parsed.returnStatusOnly
if (returnStatusOnly) {
process.logger.warn('--returnStatusOnly (-r) flag is deprecated.')
}

if (verbose && !wait) wait = true

const { sasjs, authConfig } = await getSASjsAndAuthConfig(target).catch(
Expand Down
10 changes: 10 additions & 0 deletions src/commands/job/spec/jobCommand.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ describe('JobCommand', () => {
expect(returnCode).toEqual(ReturnCode.Success)
})
})

it('should log deprecation warning if returnStatusOnly flag is present', async () => {
jest.spyOn(process.logger, 'warn')

await executeCommandWrapper([jobPath, '--returnStatusOnly'])

expect(process.logger.warn).toHaveBeenCalledWith(
'--returnStatusOnly (-r) flag is deprecated.'
)
})
})

const setupMocksForViya = () => {
Expand Down

0 comments on commit dd3a6e9

Please sign in to comment.