Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onFinishCommand is not a function #1947

Closed
Baker68 opened this issue May 16, 2021 · 3 comments
Closed

onFinishCommand is not a function #1947

Baker68 opened this issue May 16, 2021 · 3 comments

Comments

@Baker68
Copy link

Baker68 commented May 16, 2021

code :

yargs(hideBin(process.argv))
  .parserConfiguration({
    'unknown-options-as-args': true,
  })
  .command(commands)
  .demandCommand(1)
  .completion('completion')
  .strict()
  .help()
  .wrap(120)
  .middleware(middleware)
  .fail((msg: string, err: Error, yargs: Argv) => {
    yargs.showHelp();
  })
  .onFinishCommand((success) => {
    console.log(success);
  })
  .scriptName('kit')
  .showHelpOnFail(true, 'Sorry, we could not figure out what you want.')
  .version('2.0')
  .epilogue('Epilogue test').argv;

If I remove the onFinishCommand call, it works just fine.
Here is the full error message :

/home/mypc/projects/my-first-yargs-project/src/index.ts:44
  .onFinishCommand((success) => {
   ^
TypeError: yargs_1.default(...).parserConfiguration(...).command(...).demandCommand(...).completion(...).strict(...).help(...).wrap(...).middleware(...).fail(...).onFinishCommand is not a function
    at Object.<anonymous> (/home/mypc/projects/my-first-yargs-project/src/index.ts:44:4)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Module.m._compile (/home/mypc/projects/my-first-yargs-project/node_modules/ts-node/src/index.ts:1056:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Object.require.extensions.<computed> [as .ts] (/home/mypc/projects/my-first-yargs-project/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at main (/home/mypc/projects/my-first-yargs-project/node_modules/ts-node/src/bin.ts:198:14)
    at Object.<anonymous> (/home/mypc/projects/my-first-yargs-project/node_modules/ts-node/src/bin.ts:288:3)
@kitesi
Copy link
Contributor

kitesi commented May 21, 2021

onFinishCommand was removed, PR which removed it: #1823

@Baker68
Copy link
Author

Baker68 commented May 21, 2021

@Karizma , OK.
I can still make use of .fail() in conjunction with await to check if all commands have been successfully executed.
Thanks for your time.

@Baker68 Baker68 closed this as completed May 21, 2021
@bbrk24
Copy link

bbrk24 commented Apr 16, 2022

onFinishCommand is still included in the latest version of @types/yargs. If it's not included in the JavaScript, shouldn't it be removed from the type declarations too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants