Skip to content

Commit d20f49e

Browse files
committed
code review
1 parent cb0970f commit d20f49e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"test:coverage": "c8 npm test",
1515
"test:ci": "c8 --reporter=lcov node --test --experimental-test-module-mocks --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=spec --test-reporter-destination=stdout",
1616
"test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots",
17-
"test:watch": "node --run test --watch",
17+
"test:watch": "node --test --experimental-test-module-mocks --watch",
1818
"prepare": "husky",
1919
"run": "node bin/cli.mjs",
2020
"watch": "node --watch bin/cli.mjs"

src/utils/parser.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import { readFile } from 'node:fs/promises';
99
*/
1010
export const loadFromURL = async url => {
1111
const parsedUrl = url instanceof URL ? url : URL.parse(url);
12-
return !parsedUrl || parsedUrl.protocol === 'file:'
13-
? readFile(url, 'utf-8')
14-
: (await fetch(parsedUrl)).text();
12+
13+
if (!parsedUrl || parsedUrl.protocol === 'file:') {
14+
// Load from file system
15+
return readFile(url, 'utf-8');
16+
} else {
17+
// Load from network
18+
const response = await fetch(parsedUrl);
19+
return response.text();
20+
}
1521
};

0 commit comments

Comments
 (0)