File tree Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,19 @@ module.exports = {
1414 "@swc-node/jest" ,
1515 {
1616 module : "commonjs" ,
17- swc : { minify : false , sourceMaps : "inline" } ,
17+ swc : {
18+ jsc : {
19+ target : "es2020" ,
20+ parser : {
21+ syntax : "typescript" ,
22+ tsx : false ,
23+ } ,
24+ } ,
25+ sourceMaps : "inline" ,
26+ minify : false ,
27+ } ,
1828 } ,
1929 ] ,
2030 } ,
2131 transformIgnorePatterns : [ "/node_modules/" , "\\.pnp\\.[^\\/]+$" ] ,
22- } ;
32+ } ;
Original file line number Diff line number Diff line change 1+ import { promises as fs } from "fs" ;
12import * as p from "path" ;
2- import { Flow } from "../models/Flow" ;
3- import fs from "fs" ;
43import { convert } from "xmlbuilder2" ;
4+
5+ import { Flow } from "../models/Flow" ;
56import { ParsedFlow } from "../models/ParsedFlow" ;
67
78export async function parse ( selectedUris : string [ ] ) : Promise < ParsedFlow [ ] > {
89 const parseResults : ParsedFlow [ ] = [ ] ;
10+
911 for ( const uri of selectedUris ) {
1012 try {
1113 const normalizedURI = p . normalize ( uri ) ;
12- const content = await fs . readFileSync ( normalizedURI ) ;
13- const xmlString = content . toString ( ) ;
14- const flowObj = convert ( xmlString , { format : "object" } ) ;
14+ const content = await fs . readFile ( normalizedURI , "utf8" ) ;
15+ const flowObj = convert ( content , { format : "object" } ) ;
1516 parseResults . push ( new ParsedFlow ( uri , new Flow ( uri , flowObj ) ) ) ;
16- } catch ( e ) {
17- parseResults . push ( new ParsedFlow ( uri , undefined , e . errorMessage ) ) ;
17+ } catch ( e : any ) {
18+ parseResults . push (
19+ new ParsedFlow ( uri , undefined , e . message ?? e . toString ( ) )
20+ ) ;
1821 }
1922 }
23+
2024 return parseResults ;
2125}
Original file line number Diff line number Diff line change 1+ import * as core from "../src" ;
2+
3+ test ( "core exports sanity" , ( ) => {
4+ console . log ( Object . keys ( core ) ) ;
5+ expect ( core . scan ) . toBeDefined ( ) ;
6+ expect ( core . parse ) . toBeDefined ( ) ;
7+ } ) ;
You can’t perform that action at this time.
0 commit comments