Skip to content

Commit 4f5c085

Browse files
committed
clone object in test helper, fix linting errors
1 parent ec34b4c commit 4f5c085

File tree

4 files changed

+261
-103
lines changed

4 files changed

+261
-103
lines changed

lib/resolve-external.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = resolveExternal;
2121
* The promise resolves once all JSON references in the schema have been resolved,
2222
* including nested references that are contained in externally-referenced files.
2323
*/
24-
function resolveExternal(parser, options) {
24+
function resolveExternal (parser, options) {
2525
if (!options.resolve.external) {
2626
// Nothing to resolve, so exit early
2727
return Promise.resolve();
@@ -36,7 +36,8 @@ function resolveExternal(parser, options) {
3636
options
3737
);
3838
return Promise.all(promises);
39-
} catch (e) {
39+
}
40+
catch (e) {
4041
return Promise.reject(e);
4142
}
4243
}
@@ -56,7 +57,7 @@ function resolveExternal(parser, options) {
5657
* If any of the JSON references point to files that contain additional JSON references,
5758
* then the corresponding promise will internally reference an array of promises.
5859
*/
59-
function crawl(obj, path, $refs, options, external, seen) {
60+
function crawl (obj, path, $refs, options, external, seen) {
6061
seen = seen || new Set();
6162
let promises = [];
6263

@@ -69,7 +70,8 @@ function crawl(obj, path, $refs, options, external, seen) {
6970
seen.add(obj); // Track previously seen objects to avoid infinite recursion
7071
if ($Ref.isExternal$Ref(obj)) {
7172
promises.push(resolve$Ref(obj, path, $refs, options));
72-
} else {
73+
}
74+
else {
7375
if (external && $Ref.is$Ref(obj)) {
7476
/* Correct the reference in the external document so we can resolve it */
7577
let withoutHash = url.stripHash(path);
@@ -106,7 +108,7 @@ function crawl(obj, path, $refs, options, external, seen) {
106108
* The promise resolves once all JSON references in the object have been resolved,
107109
* including nested references that are contained in externally-referenced files.
108110
*/
109-
async function resolve$Ref($ref, path, $refs, options) {
111+
async function resolve$Ref ($ref, path, $refs, options) {
110112
// console.log('Resolving $ref pointer "%s" at %s', $ref.$ref, path);
111113

112114
let resolvedPath = url.resolve(path, $ref.$ref);
@@ -128,7 +130,8 @@ async function resolve$Ref($ref, path, $refs, options) {
128130
let promises = crawl(result, withoutHash + "#", $refs, options, true);
129131

130132
return Promise.all(promises);
131-
} catch (err) {
133+
}
134+
catch (err) {
132135
if (!options.continueOnError || !isHandledError(err)) {
133136
throw err;
134137
}

test/specs/absolute-root/absolute-root.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ describe("When executed in the context of root directory", () => {
2121
/**
2222
* A mock `process.cwd()` implementation that always returns the root diretory
2323
*/
24-
function mockProcessCwd() {
24+
function mockProcessCwd () {
2525
return root;
2626
}
2727

2828
/**
2929
* Temporarily mocks `process.cwd()` while calling the real `url.cwd()` implemenation
3030
*/
31-
function mockUrlCwd() {
31+
function mockUrlCwd () {
3232
try {
3333
process.cwd = mockProcessCwd;
3434
return originalUrlCwd.apply(null, arguments);
35-
} finally {
35+
}
36+
finally {
3637
process.cwd = originalProcessCwd;
3738
}
3839
}

0 commit comments

Comments
 (0)