Skip to content

Commit 7d47a36

Browse files
committed
fix: windows paths in ajv require path
1 parent 7082aef commit 7d47a36

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app-config-schema/src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,15 @@ export async function loadSchema({
174174
const resolvedAjvPath = join(require.resolve('ajv/package.json'), '..');
175175
const resolvedAjvFormatsPath = join(require.resolve('ajv-formats/package.json'), '..');
176176

177-
code = code.replace(/require\("ajv\//g, `require("${resolvedAjvPath}/`);
178-
code = code.replace(/require\("ajv-formats\//g, `require("${resolvedAjvFormatsPath}/`);
177+
code = code.replace(
178+
/require\("ajv\/(.+)"\)/g,
179+
(_, match) => `require("${join(resolvedAjvPath, match).replaceAll('\\', '\\\\\\\\')}")`,
180+
);
181+
182+
code = code.replace(
183+
/require\("ajv-formats\/(.+)"\)/g,
184+
(_, match) => `require("${join(resolvedAjvFormatsPath, match).replaceAll('\\', '\\\\\\\\')}")`,
185+
);
179186

180187
return code;
181188
},

0 commit comments

Comments
 (0)