-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Expand file tree
/
Copy pathvitest.helpers.ts
More file actions
36 lines (29 loc) · 779 Bytes
/
vitest.helpers.ts
File metadata and controls
36 lines (29 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { platform } from 'node:os';
const WINDOWS_PLATFORM = 'win32';
// Implement these whenever needed...
// const MACOS_PLATFORM = 'darwin';
// const LINUX_PLATFORM = 'linux';
let currentPlatform: NodeJS.Platform;
const getPlatform = () => {
if (!currentPlatform) {
currentPlatform = platform();
}
return currentPlatform;
};
function skipOn(platfm: NodeJS.Platform) {
return (fn: Function) => {
if (getPlatform() !== platfm) {
fn();
}
};
}
function onlyOn(platfm: NodeJS.Platform) {
return (fn: Function) => {
if (getPlatform() === platfm) {
fn();
}
};
}
export const IS_WINDOWS = getPlatform() === WINDOWS_PLATFORM;
export const skipWindows = skipOn(WINDOWS_PLATFORM);
export const onlyWindows = onlyOn(WINDOWS_PLATFORM);