1
1
import { preprocess } from '@sveltejs/site-kit/markdown/preprocess' ;
2
2
import path from 'node:path' ;
3
- import { cpSync , mkdirSync , readFileSync , readdirSync , writeFileSync } from 'node:fs' ;
3
+ import fs from 'node:fs' ;
4
4
import ts from 'typescript' ;
5
5
import glob from 'tiny-glob/sync' ;
6
6
import { fileURLToPath } from 'node:url' ;
@@ -67,7 +67,7 @@ const packages: Package[] = [
67
67
}
68
68
69
69
const dir = kit_base + 'src/types/synthetic' ;
70
- for ( const file of readdirSync ( dir ) ) {
70
+ for ( const file of fs . readdirSync ( dir ) ) {
71
71
if ( ! file . endsWith ( '.md' ) ) continue ;
72
72
73
73
const comment = strip_origin ( read_d_ts_file ( `${ dir } /${ file } ` ) ) ;
@@ -133,7 +133,7 @@ const packages: Package[] = [
133
133
*/
134
134
if ( process . env . USE_GIT === 'true' ) {
135
135
try {
136
- mkdirSync ( REPOS ) ;
136
+ fs . mkdirSync ( REPOS ) ;
137
137
} catch {
138
138
// ignore if it already exists
139
139
}
@@ -142,16 +142,19 @@ if (process.env.USE_GIT === 'true') {
142
142
}
143
143
144
144
for ( const pkg of packages ) {
145
- cpSync ( `${ pkg . local } /${ pkg . docs } ` , `${ DOCS } /${ pkg . name } ` , { recursive : true } ) ;
146
- migrate_meta_json ( `${ DOCS } /${ pkg . name } ` ) ;
145
+ const dest = `${ DOCS } /${ pkg . name } ` ;
146
+
147
+ fs . rmSync ( dest , { force : true , recursive : true } ) ;
148
+ fs . cpSync ( `${ pkg . local } /${ pkg . docs } ` , dest , { recursive : true } ) ;
149
+ migrate_meta_json ( dest ) ;
147
150
148
151
const modules = await pkg . process_modules ( await read_types ( `${ pkg . local } /${ pkg . pkg } /` , [ ] ) , pkg ) ;
149
152
150
- const files = glob ( `${ DOCS } / ${ pkg . name } /**/*.md` ) ;
153
+ const files = glob ( `${ dest } /**/*.md` ) ;
151
154
152
155
for ( const file of files ) {
153
- const content = await preprocess ( readFileSync ( file , 'utf-8' ) , modules ) ;
156
+ const content = await preprocess ( fs . readFileSync ( file , 'utf-8' ) , modules ) ;
154
157
155
- writeFileSync ( file , content ) ;
158
+ fs . writeFileSync ( file , content ) ;
156
159
}
157
160
}
0 commit comments