Comments (8)
✅ The problem can be bypassed by programmatically importing const validateSchema = require('yaml-schema-validator/src')
as a workaround.
from schema-validator.
I'm using Node 10, 12 and 13 in my project and they all had this problem.
from schema-validator.
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.
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.
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.
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.
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.
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)
- Logging should be optional HOT 2
- how to validate array of elements? HOT 5
- Validate Regex? HOT 3
- Compare an object structure directly with another object HOT 1
- multi level yml check HOT 6
- Wildcard parent
- Using with yargs, it overrides options HOT 2
- CLI: return a nonzero status when validation fails HOT 1
- `Schema` - ReferenceError: Schema is not defined HOT 2
- validateSchema() will always returns Errors+Warnings list irrespective of what log level is set
- Unable to run `schema` on MacOS due to wrong line endings
- Bug in validate dependency (validation of required fields of optional objects)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schema-validator.