Skip to content

Commit aa252e6

Browse files
committed
fix: closes vuejs#25, jscodeshift failed to parse some files with special
syntax
1 parent a820620 commit aa252e6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/wrapAstTransformation.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ export default function astTransformationToJSCodeshiftModule<Params = any>(
1515
): Transform {
1616
const transform: Transform = (file, api, options: Params) => {
1717
const j = api.jscodeshift
18-
const root = j(file.source)
18+
let root
19+
try {
20+
root = j(file.source)
21+
} catch (err) {
22+
console.error(
23+
`JSCodeshift failed to parse ${file.path},` +
24+
` please check whether the syntax is valid`
25+
)
26+
return
27+
}
1928

2029
transformAST({ root, j, filename: file.path }, options)
2130

0 commit comments

Comments
 (0)