This repository was archived by the owner on Jan 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Move to npm run test in vscode launch config #1013
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| * Licensed under the MIT License. | ||
| */ | ||
|
|
||
| import ajv from 'ajv'; | ||
| import Ajv = require('ajv') | ||
| import parser from '@apidevtools/json-schema-ref-parser' | ||
|
|
||
| let getUri: any = require('get-uri') | ||
|
|
@@ -28,16 +28,15 @@ export class SchemaTracker { | |
| // Map from dialog path to kind. | ||
| pathToKind: Map<string, string> | ||
|
|
||
| private readonly validator: ajv.Ajv | ||
| private readonly validator = new Ajv({logger: false}); | ||
|
|
||
| constructor() { | ||
| this.kindToKind = new Map<string, Kind>() | ||
| this.pathToKind = new Map<string, string>() | ||
| // NOTE: This is so that ajv doesn't complain about extra keywords around $ref | ||
| this.validator = new ajv({logger: false}) | ||
| } | ||
|
|
||
| async getValidator(schemaPath: string): Promise<[ajv.ValidateFunction, boolean]> { | ||
| async getValidator(schemaPath: string): Promise<[Ajv.ValidateFunction, boolean]> { | ||
| let validator = this.validator.getSchema(schemaPath) | ||
| let added = false | ||
| if (!validator) { | ||
|
|
@@ -82,11 +81,15 @@ export class SchemaTracker { | |
| this.validator.addSchema(metaSchema, metaSchemaName) | ||
| } | ||
| this.validator.addSchema(fullSchema, schemaPath) | ||
| validator = this.validator.getSchema(schemaPath) as ajv.ValidateFunction | ||
| validator = this.validator.getSchema(schemaPath) | ||
| if (!validator) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds a bit of safety rather than relying on casting to implicitly remove the potential for an undefined result. |
||
| throw new Error(`Could not get validator for schema ${schemaPath}`) | ||
| } | ||
| } catch (err) { | ||
| throw new Error(`Could not use schema ${schemaPath}\n${err.message}`) | ||
| } | ||
| } | ||
|
|
||
| return [validator, added] | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is discussed here: ajv-validator/ajv#1230
It looks like upgrading to v7 would give us better ES import support, but it's not a trivial upgrade so I'm moving back to require for this (and
globbywhich appears to have a similar problem).