File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,19 @@ export default defineBuildConfig({
14
14
hooks : {
15
15
'build:done' : async ( ) => {
16
16
for ( const file of await glob ( './dist/*.d.{cts,mts,ts}' ) ) {
17
- const content = await fs . readFile ( file , 'utf-8' )
17
+ let content = await fs . readFile ( file , 'utf-8' )
18
18
// Override `options` type on dist dts only
19
- const newContent = content . replace (
19
+ let newContent = content . replace (
20
20
'class MarkdownItAsync extends MarkdownIt {' ,
21
21
'class MarkdownItAsync extends MarkdownIt {\n // @ts-ignore\n options: MarkdownItAsyncOptions' ,
22
22
)
23
+ if ( content === newContent )
24
+ throw new Error ( `Failed to replace for ${ file } ` )
25
+ content = newContent
26
+ newContent = content . replace (
27
+ 'import MarkdownIt' ,
28
+ 'import type MarkdownIt' ,
29
+ )
23
30
if ( content === newContent )
24
31
throw new Error ( `Failed to replace for ${ file } ` )
25
32
await fs . writeFile ( file , newContent , 'utf-8' )
You can’t perform that action at this time.
0 commit comments