File tree 2 files changed +11
-6
lines changed
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 59
59
"mime-types" : " ^2.1.35" ,
60
60
"pdf-ts" : " ^0.0.2" ,
61
61
"turndown" : " ^7.2.0" ,
62
- "xlsx" : " ^0.18.5"
62
+ "xlsx" : " ^0.18.5" ,
63
+ "ai" : " ^4.0.22"
63
64
},
64
65
"peerDependencies" : {
65
- "ai" : " ^4.0.22" ,
66
66
"youtube-transcript" : " ^1.2.1" ,
67
67
"unzipper" : " ^0.12.3"
68
68
},
69
69
"peerDependenciesMeta" : {
70
70
"youtube-transcript" : {
71
71
"optional" : true
72
72
},
73
- "ai" : {
74
- "optional" : true
75
- },
76
73
"unzipper" : {
77
74
"optional" : true
78
75
}
Original file line number Diff line number Diff line change 1
1
import { ConverterOptions , ConverterResult , DocumentConverter } from "../types" ;
2
2
import * as fs from "fs/promises" ;
3
3
import * as path from "path" ;
4
- import * as unzipper from "unzipper" ;
5
4
6
5
export class ZipConverter implements DocumentConverter {
7
6
async convert (
@@ -29,6 +28,15 @@ export class ZipConverter implements DocumentConverter {
29
28
text_content : `[ERROR] Invalid zip file path: ${ localPath } `
30
29
} ;
31
30
}
31
+ let unzipper ;
32
+ try {
33
+ unzipper = await import ( "unzipper" ) . then ( ( mod ) => mod . default ) ;
34
+ } catch ( error ) {
35
+ console . error (
36
+ "Optional dependency 'unzipper' is not installed. Run `npm install unzipper` to enable this feature."
37
+ ) ;
38
+ return null ;
39
+ }
32
40
try {
33
41
await fs . mkdir ( newFolder , { recursive : true } ) ;
34
42
const zip = await unzipper . Open . file ( localPath ) ;
You can’t perform that action at this time.
0 commit comments