File tree Expand file tree Collapse file tree 3 files changed +8
-12
lines changed
Expand file tree Collapse file tree 3 files changed +8
-12
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ import { extname } from 'node:path';
55import { globSync } from 'glob' ;
66import { read } from 'to-vfile' ;
77
8+ import createQueries from '../../utils/queries/index.mjs' ;
89import { getRemark } from '../../utils/remark.mjs' ;
9- import createQueries from '../utils/queries/index.mjs' ;
1010
1111const { updateStabilityPrefixToLink } = createQueries ( ) ;
1212const 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
Original file line number Diff line number Diff 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 */
1111export 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} ;
You can’t perform that action at this time.
0 commit comments