Skip to content

Commit 479a3ce

Browse files
committed
More updates for windows paths (in asyncLoad, tests, and build)
1 parent a0fd588 commit 479a3ce

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

components/bin/build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ function processParts(parts) {
193193
function processLines(file, objects) {
194194
if (objects.length === 0) return [];
195195
const base = path.dirname(file).replace(/^\.$/, '');
196-
const dir = (PREFIX ? path.join(PREFIX, base) : base);
196+
const dir = (PREFIX ? noramlize(path.join(PREFIX, base)) : base);
197197
const dots = dir.replace(/[^\/]+/g, '..') || '.';
198-
const relative = path.join(dots, '..', JS, dir, path.basename(file)).replace(/\.ts$/, '.js');
198+
const relative = normalize(path.join(dots, '..', JS, dir, path.basename(file))).replace(/\.ts$/, '.js');
199199
const name = path.parse(file).name;
200200
const lines = (target === 'mjs' ? [] : [
201201
'"use strict";',
@@ -264,7 +264,7 @@ function getExtraDirectories() {
264264
let prefix = '';
265265
let indent = INDENT;
266266
let postfix = '';
267-
for (let name of PREFIX.split(/\//)) {
267+
for (let name of PREFIX.split('/')) {
268268
if (name.match(/[^a-zA-Z0-9]/)) {
269269
name = `"${name}"`;
270270
}
@@ -293,7 +293,7 @@ function processGlobal() {
293293
const packages = [];
294294
PACKAGE = PACKAGE.sort(sortDir);
295295
while (PACKAGE.length) {
296-
const dir = path.dirname(PACKAGE[0]).split(path.sep)[0];
296+
const dir = path.dirname(PACKAGE[0]).split('/')[0];
297297
packages.push(processPackage(lines, indent, dir));
298298
}
299299
const name = (ID.match(/[^a-zA-Z0-9_]/) ? `"${ID}"` : ID);

testsuite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@jest/globals": "^29.7.0",
17-
"@mathjax/mathjax-bbm-font-extension": "0.4.2-beta.8",
17+
"@mathjax/mathjax-bbm-font-extension": "^4.0.0",
1818
"@types/jest": "^29.5.14",
1919
"jest": "^29.7.0",
2020
"ts-jest": "^29.3.4",

testsuite/pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testsuite/tests/util/Context-node.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const OS = {
1818
describe('context object', () => {
1919

2020
test('context', () => {
21-
if (process.platform as string === 'Windows') {
21+
if (OS === 'Windows') {
2222
expect(context.path('C:\\test.js')).toBe('C:/test.js');
2323
} else {
2424
expect(context.path('C:\\test.js')).toBe('C:\\test.js');

ts/util/asyncLoad/esm.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@
2222
*/
2323

2424
import { mathjax } from '../../mathjax.js';
25+
import { context } from '../context.js';
2526

26-
let root = new URL(import.meta.url).href.replace(
27+
let root = context.path(new URL(import.meta.url, 'file://').href).replace(
2728
/\/util\/asyncLoad\/esm.js$/,
2829
'/'
2930
);
3031

3132
if (!mathjax.asyncLoad) {
3233
mathjax.asyncLoad = async (name: string) => {
33-
const file = name.charAt(0) === '.' ? new URL(name, root).pathname : name;
34+
const file = name.charAt(0) === '.' ? new URL(name, root).href : name;
3435
return import(file).then((result) => result.default ?? result);
3536
};
3637
}
@@ -39,7 +40,7 @@ if (!mathjax.asyncLoad) {
3940
* @param {string} url the base URL to use for loading relative paths
4041
*/
4142
export function setBaseURL(url: string) {
42-
root = new URL(url, 'file://').href;
43+
root = new URL(context.path(url), 'file://').href;
4344
if (!root.match(/\/$/)) {
4445
root += '/';
4546
}

ts/util/asyncLoad/system.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
*/
2323

2424
import { mathjax } from '../../mathjax.js';
25+
import { context } from '../context.js';
2526

2627
declare const System: { import: (name: string, url?: string) => any };
2728
declare const __dirname: string;
2829

29-
let root = 'file://' + __dirname.replace(/\/[^/]*\/[^/]*$/, '/');
30+
let root = 'file://' + context.path(__dirname).replace(/\/[^/]*\/[^/]*$/, '/');
3031

3132
if (!mathjax.asyncLoad && typeof System !== 'undefined' && System.import) {
3233
mathjax.asyncLoad = (name: string) => {
@@ -41,7 +42,7 @@ if (!mathjax.asyncLoad && typeof System !== 'undefined' && System.import) {
4142
* @param {string} url the base URL to use for loading relative paths
4243
*/
4344
export function setBaseURL(url: string) {
44-
root = new URL(url, 'file://').href;
45+
root = new URL(context.path(url), 'file://').href;
4546
if (!root.match(/\/$/)) {
4647
root += '/';
4748
}

0 commit comments

Comments
 (0)