Skip to content

Commit 229698f

Browse files
authored
sync-docs -w (#329)
1 parent 9b10879 commit 229698f

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

apps/svelte.dev/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"@types/node": "^20.14.2",
7575
"@vercel/speed-insights": "^1.0.0",
7676
"browserslist": "^4.23.1",
77+
"chokidar": "^4.0.1",
7778
"degit": "^2.8.4",
7879
"dotenv": "^16.4.5",
7980
"esbuild": "^0.21.5",

apps/svelte.dev/scripts/sync-docs/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'node:path';
33
import fs from 'node:fs';
44
import ts from 'typescript';
55
import glob from 'tiny-glob/sync';
6+
import chokidar from 'chokidar';
67
import { fileURLToPath } from 'node:url';
78
import { clone_repo, migrate_meta_json, strip_origin } from './utils';
89
import { get_types, read_d_ts_file, read_types } from './types';
@@ -123,7 +124,7 @@ if (process.env.USE_GIT === 'true') {
123124
);
124125
}
125126

126-
for (const pkg of packages) {
127+
async function sync(pkg: Package) {
127128
const dest = `${DOCS}/${pkg.name}`;
128129

129130
fs.rmSync(dest, { force: true, recursive: true });
@@ -140,3 +141,17 @@ for (const pkg of packages) {
140141
fs.writeFileSync(file, content);
141142
}
142143
}
144+
145+
for (const pkg of packages) {
146+
await sync(pkg);
147+
}
148+
149+
if (process.argv.includes('-w') || process.argv.includes('--watch')) {
150+
for (const pkg of packages) {
151+
chokidar
152+
.watch(`${REPOS}/${pkg.name}/${pkg.docs}`, { ignoreInitial: true })
153+
.on('all', (event) => {
154+
sync(pkg);
155+
});
156+
}
157+
}

pnpm-lock.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)