Skip to content

Commit b16fd2d

Browse files
committed
refactor(build-typedoc): fix path resolution to work in windows
1 parent 4c5270c commit b16fd2d

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

scripts/build-typedoc.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
23
import { create } from 'browser-sync';
34
import watch from 'node-watch';
45
import { Application } from 'typedoc';
56
import report from './report.mjs';
67

8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
11+
const toPosix = (p) => p.replace(/\\/g, '/');
712
const browserSync = create();
8-
const ROOT = path.join.bind(null, path.resolve('./'));
13+
const ROOT = (...segments) =>
14+
toPosix(path.resolve(__dirname, '..', ...segments));
915

1016
const TYPEDOC = {
1117
PLUGINS: {
@@ -15,26 +21,25 @@ const TYPEDOC = {
1521
'typedoc-plugin-localization/dist/index.js'
1622
),
1723
},
18-
OUTPUT: ROOT(path.posix.join('dist', 'docs', 'typescript')),
24+
OUTPUT: ROOT('dist', 'docs', 'typescript'),
1925
EXPORT_JSON_PATH: ROOT(
20-
path.posix.join(
21-
'dist',
22-
'docs',
23-
'typescript-exported',
24-
'ignite-ui-web-components.json'
25-
)
26+
'dist',
27+
'docs',
28+
'typescript-exported',
29+
'ignite-ui-web-components.json'
2630
),
2731
IMPORT_JSON_PATH: ROOT(
28-
path.posix.join(
29-
'i18nRepo',
30-
'typedoc',
31-
'ja',
32-
'ignite-ui-web-components.json'
33-
)
32+
'i18nRepo',
33+
'typedoc',
34+
'ja',
35+
'ignite-ui-web-components.json'
3436
),
35-
PROJECT_PATH: ROOT(path.posix.join('src', 'index.ts')),
37+
PROJECT_PATH: ROOT('src', 'index.ts'),
3638
TEMPLATE_STRINGS_PATH: ROOT(
37-
path.posix.join('extras', 'template', 'strings', 'shell-strings.json')
39+
'extras',
40+
'template',
41+
'strings',
42+
'shell-strings.json'
3843
),
3944
};
4045

0 commit comments

Comments
 (0)