Code Monkey home page Code Monkey logo

Comments (8)

bkimminich avatar bkimminich commented on June 27, 2024 2

✅ The problem can be bypassed by programmatically importing const validateSchema = require('yaml-schema-validator/src') as a workaround.

from schema-validator.

bkimminich avatar bkimminich commented on June 27, 2024 1

I'm using Node 10, 12 and 13 in my project and they all had this problem.

from schema-validator.

bkimminich avatar bkimminich commented on June 27, 2024

I have observed the exact same behavior with Jest. Having yaml-schema-validator in the package.json and installed does not cause issues for me. Only when it is imported with require('yaml-schema-validator') in my project, the error: unknown option xxxxx errors arise.

See jestjs/jest#9379 for my original report assuming Jest would be the culprit. It contains steps to reproduce the issue from the failing commits from my Travis-CI pipeline.

from schema-validator.

bkimminich avatar bkimminich commented on June 27, 2024

I just tried with "yaml-schema-validator": "1.0.0" pinned dependency and the issue exists there already, so it is probably there from the beginning and not a regression.

C:\Data\GitHub\juice-shop>npm run frisby

> [email protected] frisby C:\Data\GitHub\juice-shop
> nyc --report-dir=./build/reports/coverage/api-tests jest --silent --runInBand --forceExit

Determining test suites to run...error: unknown option `--silent'

from schema-validator.

bkimminich avatar bkimminich commented on June 27, 2024

Removing the only const validateSchema = require('yaml-schema-validator') in my code base (which does not even have to be called - it just has to be imported) makes my test suite run perfectly fine again.

from schema-validator.

bkimminich avatar bkimminich commented on June 27, 2024

I think the culprit is the design of the module as a mix of CLI and programmatic library all in one. I have no experience with the commander module, but I suspect that this code section is somehow "eating" the command line arguments of the jest or mocha call:

program
  .version(pkg.version)
  .command('validate')
  .option('-f, --filePath <filePath>', 'path to the target file for validating')
  .option('-j, --json','passed if target file is in JSON format')
  .option('-s, --schema [schemaPath]','path to an external schema.js file')
  .action(validateSchema);

program.parse(process.argv);

if(process.argv.includes('help')) {
  help()
}

If this would be extracted into its own file - which then serves for the CLI use case - the programmatic use case would import the actual validator only but not the CLI code.

from schema-validator.

rockon1985 avatar rockon1985 commented on June 27, 2024

thanks @bkimminich for coming up with this. It can work as a temporary workaround till I mitigate the root cause.
Looks like an issue in one of the dependencies and not in the package itself. Would certainly recommend to upgrade to node version 10+ or 11 to avoid this scenario.
Closing this issue.

from schema-validator.

alambike avatar alambike commented on June 27, 2024

Same error here running jest --coverage. Tested with the following node versions:

  • v10.24.1
  • v12.22.3
  • v14.17.4
 ●  process.exit called with "1"

      5 |
    > 6 | const validateSchema = require('yaml-schema-validator');
        |                        ^
      8 |


      at Command.Object.<anonymous>.Command.unknownOption (node_modules/yaml-schema-validator/node_modules/commander/index.js:823:11)
      at Command.Object.<anonymous>.Command.parseArgs (node_modules/yaml-schema-validator/node_modules/commander/index.js:661:12)
      at Command.Object.<anonymous>.Command.parse (node_modules/yaml-schema-validator/node_modules/commander/index.js:474:21)
      at Object.<anonymous> (node_modules/yaml-schema-validator/index.js:24:9)
      at Object.<anonymous> (src/config/settings.js:6:24)

from schema-validator.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.