Skip to content

Commit ce0b972

Browse files
committed
fix(astro): apply fast-glob Windows work-around for all \@ matches
1 parent b57a764 commit ce0b972

File tree

6 files changed

+58
-3
lines changed

6 files changed

+58
-3
lines changed

integration/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test": "vitest --testTimeout=300000"
77
},
88
"dependencies": {
9+
"@tutorialkit/theme": "workspace:*",
910
"execa": "^9.2.0",
1011
"tempy": "^3.1.0",
1112
"vitest": "^2.1.1"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import fs from 'node:fs/promises';
2+
import path from 'node:path';
3+
import { getInlineContentForPackage } from '@tutorialkit/theme';
4+
import { execa } from 'execa';
5+
import { temporaryDirectory } from 'tempy';
6+
import { afterAll, expect, test } from 'vitest';
7+
8+
const baseDir = path.resolve(__dirname, '../..');
9+
const cli = path.join(baseDir, 'packages/cli/dist/index.js');
10+
const tmp = temporaryDirectory();
11+
12+
afterAll(async () => {
13+
await fs.rm(tmp, { force: true, recursive: true });
14+
});
15+
16+
test('getInlineContentForPackage finds files from @tutorialkit/astro', async () => {
17+
await execa(
18+
'node',
19+
[cli, 'create', 'theme-test', '--install', '--no-git', '--no-start', '--package-manager', 'pnpm', '--defaults'],
20+
{ cwd: tmp },
21+
);
22+
23+
const content = getInlineContentForPackage({
24+
name: '@tutorialkit/astro',
25+
pattern: '/dist/default/**/*.astro',
26+
root: `${tmp}/theme-test`,
27+
});
28+
29+
console.log(content);
30+
expect(content.length).toBeGreaterThan(0);
31+
});

packages/theme/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
],
2929
"scripts": {
3030
"build": "tsc -b",
31-
"dev": "pnpm run build --watch --preserveWatchOutput"
31+
"dev": "pnpm run build --watch --preserveWatchOutput",
32+
"test": "vitest"
3233
},
3334
"dependencies": {
3435
"@iconify-json/ph": "^1.1.13",
@@ -38,6 +39,7 @@
3839
},
3940
"devDependencies": {
4041
"@types/node": "^22.4.1",
41-
"typescript": "^5.4.5"
42+
"typescript": "^5.4.5",
43+
"vitest": "^2.1.1"
4244
}
4345
}

packages/theme/src/index.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { fileURLToPath, URL } from 'node:url';
2+
import { expect, test } from 'vitest';
3+
import { getInlineContentForPackage } from './index.js';
4+
5+
const root = fileURLToPath(new URL('../../template', import.meta.url));
6+
7+
test('getInlineContentForPackage finds files from @tutorialkit/astro', () => {
8+
const content = getInlineContentForPackage({
9+
name: '@tutorialkit/astro',
10+
pattern: '/dist/default/**/*.astro',
11+
root,
12+
});
13+
14+
expect(content.length).toBeGreaterThan(0);
15+
});

packages/theme/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function getInlineContentForPackage({ name, pattern, root }: { name: stri
4949
const packageRoot = resolve(require.resolve(`${name}/package.json`, { paths: [root] }), '..');
5050

5151
// work-around for https://github.com/mrmlnc/fast-glob/issues/452
52-
const packagePattern = convertPathToPattern(packageRoot.replace('\\@', '/@'));
52+
const packagePattern = convertPathToPattern(packageRoot.replaceAll('\\@', '/@'));
5353

5454
return globSync(`${packagePattern}${pattern}`).map((filePath) => () => fs.readFile(filePath, { encoding: 'utf8' }));
5555
} catch {

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)