Skip to content

Commit dc26aef

Browse files
committed
refactor: windows dirname variable check
1 parent f613bd2 commit dc26aef

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

packages/docs/check-qwik-build.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,39 @@ import { spawnSync } from 'node:child_process';
88

99
let __dirname = path.dirname(new URL(import.meta.url).pathname);
1010
const isWindows = process.platform === 'win32';
11-
if (isWindows) {
11+
if (isWindows && __dirname.startsWith('/')) {
1212
// in Windows __dirname starts with a / causing errors
1313
// before
1414
// /C:/Users/{location stuff}/qwik/packages/docs
15+
__dirname = __dirname.substring(1);
16+
// after
17+
// C:/Users/{location stuff}/qwik/packages/docs
18+
}
19+
const qwikPkgDir = path.join(__dirname, '..', 'qwik', 'dist');
1520

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-
}
21+
if (!fs.existsSync(path.join(qwikPkgDir, 'core.d.ts'))) {
22+
console.warn(
23+
`\n\n=== Running 'pnpm run build.local' to generate missing imports for the docs ===\n`
24+
);
25+
const out = spawnSync('pnpm', ['run', 'build.local'], {
26+
cwd: path.join(__dirname, '..', '..'),
27+
stdio: 'inherit',
28+
});
29+
if (out.status !== 0) {
30+
console.error('Failed to build local packages');
31+
process.exit(1);
3532
}
33+
}
3634

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+
if (!fs.existsSync(path.join(__dirname, 'public', 'repl', 'repl-sw.js'))) {
36+
console.warn(
37+
`\n\n=== Running 'pnpm run build.repl-sw' to generate missing REPL service worker public/repl/repl-sw.js ===\n`
38+
);
39+
const out = spawnSync('pnpm', ['run', 'build.repl-sw'], {
40+
stdio: 'inherit',
41+
});
42+
if (out.status !== 0) {
43+
console.error('Failed to build REPL service worker');
44+
process.exit(1);
4845
}
4946
}

0 commit comments

Comments
 (0)