Skip to content

Commit dd33dcd

Browse files
committed
Use junctions instead of symlinks on Windows
1 parent 9e7d2d6 commit dd33dcd

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/tailwindcss-language-server/src/testing/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { onTestFinished, test, TestOptions } from 'vitest'
2+
import * as os from 'node:os'
23
import * as fs from 'node:fs/promises'
34
import * as path from 'node:path'
45
import * as proc from 'node:child_process'
@@ -12,6 +13,7 @@ export interface TestUtils {
1213
export interface StorageSymlink {
1314
[IS_A_SYMLINK]: true
1415
filepath: string
16+
type: 'file' | 'dir' | undefined
1517
}
1618

1719
export interface Storage {
@@ -75,10 +77,11 @@ async function setup<T>(config: TestConfig<T>): Promise<TestUtils> {
7577
}
7678

7779
const IS_A_SYMLINK = Symbol('is-a-symlink')
78-
export function symlinkTo(filepath: string): StorageSymlink {
80+
export function symlinkTo(filepath: string, type?: 'file' | 'dir'): StorageSymlink {
7981
return {
8082
[IS_A_SYMLINK]: true as const,
8183
filepath,
84+
type,
8285
}
8386
}
8487

@@ -93,7 +96,14 @@ async function prepareFileSystem(base: string, storage: Storage) {
9396

9497
if (typeof content === 'object' && IS_A_SYMLINK in content) {
9598
let target = path.resolve(base, content.filepath)
96-
await fs.symlink(target, fullPath)
99+
100+
let type: string = content.type
101+
102+
if (os.platform() === 'win32' && content.type === 'dir') {
103+
type = 'junction'
104+
}
105+
106+
await fs.symlink(target, fullPath, type)
97107
continue
98108
}
99109

packages/tailwindcss-language-server/tests/env/v4.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ defineTest({
737737
presets: [require('some-pkg/config/tailwind.config.js').default]
738738
}
739739
`,
740-
'packages/some-pkg': symlinkTo('packages/some-pkg#c3f1e'),
740+
'packages/some-pkg': symlinkTo('packages/some-pkg#c3f1e', 'dir'),
741741
'packages/some-pkg#c3f1e/package.json': json`
742742
{
743743
"name": "some-pkg",

0 commit comments

Comments
 (0)