|
1 | 1 | // verify that ../qwik/dist/core.d.ts exists or run `pnpm run build.core` in the root directory
|
2 | 2 | // Also make sure that the repl-sw.js file is present, for dev mode
|
3 | 3 | // 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'; |
7 | 4 |
|
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'; |
10 | 8 |
|
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 | + } |
22 | 35 | }
|
23 |
| -} |
24 | 36 |
|
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 | + } |
35 | 48 | }
|
36 | 49 | }
|
0 commit comments