Skip to content

Commit 3923a66

Browse files
committed
fixup!
1 parent e1e568c commit 3923a66

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

src/generators/ast-js/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default {
3737
const filePaths = itemIndices.map(idx => inputSlice[idx]);
3838

3939
return Promise.all(
40-
filePaths.map(async path => parseJsSource(await read(path)))
40+
filePaths.map(async path => parseJsSource(await read(path, 'utf-8')))
4141
);
4242
},
4343

src/generators/ast/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { extname } from 'node:path';
55
import { globSync } from 'glob';
66
import { read } from 'to-vfile';
77

8+
import createQueries from '../../utils/queries/index.mjs';
89
import { getRemark } from '../../utils/remark.mjs';
9-
import createQueries from '../utils/queries/index.mjs';
1010

1111
const { updateStabilityPrefixToLink } = createQueries();
1212
const remarkProcessor = getRemark();
@@ -40,7 +40,7 @@ export default {
4040

4141
return Promise.all(
4242
filePaths.map(async path => {
43-
const vfile = await read(path);
43+
const vfile = await read(path, 'utf-8');
4444

4545
updateStabilityPrefixToLink(vfile);
4646

src/parsers/javascript.mjs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,21 @@ import * as acorn from 'acorn';
55
/**
66
* Parses a given JavaScript file into an ESTree AST representation of it
77
*
8-
* @param {import('vfile').VFile | Promise<import('vfile').VFile>} sourceFile
8+
* @param {import('vfile').VFile} sourceFile
99
* @returns {Promise<JsProgram>}
1010
*/
1111
export const parseJsSource = async sourceFile => {
12-
// We allow the API doc VFile to be a Promise of a VFile also,
13-
// hence we want to ensure that it first resolves before we pass it to the parser
14-
const resolvedSourceFile = await Promise.resolve(sourceFile);
15-
16-
if (typeof resolvedSourceFile.value !== 'string') {
12+
if (typeof sourceFile.value !== 'string') {
1713
throw new TypeError(
18-
`expected resolvedSourceFile.value to be string but got ${typeof resolvedSourceFile.value}`
14+
`expected sourceFile.value to be string but got ${typeof sourceFile.value}`
1915
);
2016
}
2117

22-
const res = acorn.parse(resolvedSourceFile.value, {
18+
const res = acorn.parse(sourceFile.value, {
2319
allowReturnOutsideFunction: true,
2420
ecmaVersion: 'latest',
2521
locations: true,
2622
});
2723

28-
return { ...res, path: resolvedSourceFile.path };
24+
return { ...res, path: sourceFile.path };
2925
};

0 commit comments

Comments
 (0)