Skip to content

Change filesystem require to be lazy loaded, bump package versions #28

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

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const schemaWalker = require('@cloudflare/json-schema-walker');
const { Resolver } = require('@stoplight/json-ref-resolver');
const { parse } = require('@stoplight/yaml');
const fetch = require('node-fetch');
const fs = require('fs');
const readFileAsync = require('util').promisify(fs.readFile);
const oas3schema = require('./refs/oas3-schema.json');

class InvalidTypeError extends Error {
Expand Down Expand Up @@ -238,7 +236,9 @@ const resolver = new Resolver({
http: httpReader,
https: httpReader,
file: {
resolve(ref) {
resolve: async (ref) => {
const fs = require('fs');
const readFileAsync = (fs.promises && fs.promises.readFile) || require('util').promisify(fs.readFile);
return readFileAsync(ref.path(), 'utf8');
},
},
Expand Down
Loading