Skip to content

Commit e56fa22

Browse files
committed
fix check builds add windows support
1 parent 07a45f4 commit e56fa22

File tree

1 file changed

+40
-27
lines changed

1 file changed

+40
-27
lines changed

packages/docs/check-qwik-build.ts

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
11
// verify that ../qwik/dist/core.d.ts exists or run `pnpm run build.core` in the root directory
22
// Also make sure that the repl-sw.js file is present, for dev mode
33
// we need it for development and for the REPL
4-
import fs from 'fs';
5-
import path from 'path';
6-
import { spawnSync } from 'child_process';
74

8-
const __dirname = path.dirname(new URL(import.meta.url).pathname);
9-
const qwikPkgDir = path.join(__dirname, '..', 'qwik', 'dist');
5+
import fs from 'node:fs';
6+
import path from 'node:path';
7+
import { spawnSync } from 'node:child_process';
108

11-
if (!fs.existsSync(path.join(qwikPkgDir, 'core.d.ts'))) {
12-
console.warn(
13-
`\n\n=== Running 'pnpm run build.local' to generate missing imports for the docs ===\n`
14-
);
15-
const out = spawnSync('pnpm', ['run', 'build.local'], {
16-
cwd: path.join(__dirname, '..', '..'),
17-
stdio: 'inherit',
18-
});
19-
if (out.status !== 0) {
20-
console.error('Failed to build local packages');
21-
process.exit(1);
9+
let __dirname = path.dirname(new URL(import.meta.url).pathname);
10+
const isWindows = process.platform === 'win32';
11+
if (isWindows) {
12+
// in Windows __dirname starts with a / causing errors
13+
// before
14+
// /C:/Users/{location stuff}/qwik/packages/docs
15+
16+
if (__dirname.startsWith('/')) {
17+
__dirname = __dirname.substring(1);
18+
// after
19+
// C:/Users/{location stuff}/qwik/packages/docs
20+
}
21+
const qwikPkgDir = path.join(__dirname, '..', 'qwik', 'dist');
22+
23+
if (!fs.existsSync(path.join(qwikPkgDir, 'core.d.ts'))) {
24+
console.warn(
25+
`\n\n=== Running 'pnpm run build.local' to generate missing imports for the docs ===\n`
26+
);
27+
const out = spawnSync('pnpm', ['run', 'build.local'], {
28+
cwd: path.join(__dirname, '..', '..'),
29+
stdio: 'inherit',
30+
});
31+
if (out.status !== 0) {
32+
console.error('Failed to build local packages');
33+
process.exit(1);
34+
}
2235
}
23-
}
2436

25-
if (!fs.existsSync(path.join(__dirname, 'public', 'repl', 'repl-sw.js'))) {
26-
console.warn(
27-
`\n\n=== Running 'pnpm run build.repl-sw' to generate missing REPL service worker public/repl/repl-sw.js ===\n`
28-
);
29-
const out = spawnSync('pnpm', ['run', 'build.repl-sw'], {
30-
stdio: 'inherit',
31-
});
32-
if (out.status !== 0) {
33-
console.error('Failed to build REPL service worker');
34-
process.exit(1);
37+
if (!fs.existsSync(path.join(__dirname, 'public', 'repl', 'repl-sw.js'))) {
38+
console.warn(
39+
`\n\n=== Running 'pnpm run build.repl-sw' to generate missing REPL service worker public/repl/repl-sw.js ===\n`
40+
);
41+
const out = spawnSync('pnpm', ['run', 'build.repl-sw'], {
42+
stdio: 'inherit',
43+
});
44+
if (out.status !== 0) {
45+
console.error('Failed to build REPL service worker');
46+
process.exit(1);
47+
}
3548
}
3649
}

0 commit comments

Comments
 (0)