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

args is not defined into CLI error #711

Closed
7studio opened this issue Oct 6, 2021 · 2 comments
Closed

args is not defined into CLI error #711

7studio opened this issue Oct 6, 2021 · 2 comments

Comments

@7studio
Copy link
Contributor

7studio commented Oct 6, 2021

Hi,

I looked into the CLI part of style-dictonary to construct a similar thing and I found a bug when I run the command style-dictionary test or npx -p style-dictionary style-dictionary test in my case:

npx : 43 installé(s) en 3.911s
/Users/xzalawa/.npm/_npx/19473/lib/node_modules/style-dictionary/bin/style-dictionary:75
  console.error('Invalid command: %s\nSee --help for a list of available commands.', args.join(' '));
                                                                                     ^

ReferenceError: args is not defined
    at Command.<anonymous> (/Users/xzalawa/.npm/_npx/19473/lib/node_modules/style-dictionary/bin/style-dictionary:75:86)
    at Command.emit (events.js:400:28)
    at Command._parseCommand (/Users/xzalawa/.npm/_npx/19473/lib/node_modules/style-dictionary/node_modules/commander/index.js:920:16)
    at Command.parse (/Users/xzalawa/.npm/_npx/19473/lib/node_modules/style-dictionary/node_modules/commander/index.js:717:10)
    at Object.<anonymous> (/Users/xzalawa/.npm/_npx/19473/lib/node_modules/style-dictionary/bin/style-dictionary:111:9)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)

I read the documentation of the commander.js package and it seems that we should use operands instead of args like this (cf.: Custom event listeners):

// error on unknown commands
program.on('command:*', function (operands) {
  console.error('Invalid command: %s\nSee --help for a list of available commands.', operands.join(' '));
  process.exit(1);
});
@dbanksdesign
Copy link
Member

Thanks for filing this issue @7studio ! It looks like there are actually 2 issues:

  1. There is no test command
  2. In the catch-all bucket for the CLI there is an error because as you pointed out args is not defined. @chazzmoney and I looked at this yesterday and we think we have a fix for it.

@chazzmoney
Copy link
Collaborator

Fixed in #747

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

No branches or pull requests

3 participants