git0 0.2.64 → 0.2.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/test/platform.test.ts +22 -29
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git0",
|
|
3
3
|
"description": "CLI tool to search GitHub repositories, download source & releases for your system, and instantly set up, then install dependencies and open code editor.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.65",
|
|
5
5
|
"author": "vtempest",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "bun build src/cli.ts --outdir dist --target node --format esm --sourcemap",
|
package/test/platform.test.ts
CHANGED
|
@@ -1,68 +1,61 @@
|
|
|
1
|
-
import { describe, test, expect, mock, afterAll } from 'bun:test';
|
|
2
1
|
import os from 'os';
|
|
2
|
+
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
3
|
+
import { getCurrentPlatform } from '../src/platform.ts';
|
|
3
4
|
|
|
4
|
-
// `
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// untouched module back once this file is done.
|
|
9
|
-
const realOs = os;
|
|
10
|
-
|
|
5
|
+
// Spy on the `os` default export rather than mocking the whole module: it is
|
|
6
|
+
// the same object `src/platform.ts` imports, and the spies are restored after
|
|
7
|
+
// every test so nothing leaks into the other suites (download.test.ts calls
|
|
8
|
+
// os.tmpdir()).
|
|
11
9
|
function mockPlatform(platform: string, arch: string) {
|
|
12
|
-
|
|
10
|
+
vi.spyOn(os, 'platform').mockReturnValue(platform as NodeJS.Platform);
|
|
11
|
+
vi.spyOn(os, 'arch').mockReturnValue(arch);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
vi.restoreAllMocks();
|
|
17
16
|
});
|
|
18
17
|
|
|
19
18
|
describe('getCurrentPlatform', () => {
|
|
20
|
-
test('maps darwin/x64 → macos/x86_64',
|
|
19
|
+
test('maps darwin/x64 → macos/x86_64', () => {
|
|
21
20
|
mockPlatform('darwin', 'x64');
|
|
22
|
-
const
|
|
23
|
-
const p = fn();
|
|
21
|
+
const p = getCurrentPlatform();
|
|
24
22
|
expect(p.os).toBe('macos');
|
|
25
23
|
expect(p.arch).toBe('x86_64');
|
|
26
24
|
expect(p.platform).toBe('darwin');
|
|
27
25
|
expect(p.architecture).toBe('x64');
|
|
28
26
|
});
|
|
29
27
|
|
|
30
|
-
test('maps win32/ia32 → windows/i386',
|
|
28
|
+
test('maps win32/ia32 → windows/i386', () => {
|
|
31
29
|
mockPlatform('win32', 'ia32');
|
|
32
|
-
const
|
|
33
|
-
const p = fn();
|
|
30
|
+
const p = getCurrentPlatform();
|
|
34
31
|
expect(p.os).toBe('windows');
|
|
35
32
|
expect(p.arch).toBe('i386');
|
|
36
33
|
});
|
|
37
34
|
|
|
38
|
-
test('maps linux/arm64 → linux/arm64',
|
|
35
|
+
test('maps linux/arm64 → linux/arm64', () => {
|
|
39
36
|
mockPlatform('linux', 'arm64');
|
|
40
|
-
const
|
|
41
|
-
const p = fn();
|
|
37
|
+
const p = getCurrentPlatform();
|
|
42
38
|
expect(p.os).toBe('linux');
|
|
43
39
|
expect(p.arch).toBe('arm64');
|
|
44
40
|
});
|
|
45
41
|
|
|
46
|
-
test('maps darwin/arm64 → macos/arm64 (Apple Silicon)',
|
|
42
|
+
test('maps darwin/arm64 → macos/arm64 (Apple Silicon)', () => {
|
|
47
43
|
mockPlatform('darwin', 'arm64');
|
|
48
|
-
const
|
|
49
|
-
const p = fn();
|
|
44
|
+
const p = getCurrentPlatform();
|
|
50
45
|
expect(p.os).toBe('macos');
|
|
51
46
|
expect(p.arch).toBe('arm64');
|
|
52
47
|
});
|
|
53
48
|
|
|
54
|
-
test('passes through unknown platform/arch as-is',
|
|
49
|
+
test('passes through unknown platform/arch as-is', () => {
|
|
55
50
|
mockPlatform('freebsd', 'mips');
|
|
56
|
-
const
|
|
57
|
-
const p = fn();
|
|
51
|
+
const p = getCurrentPlatform();
|
|
58
52
|
expect(p.os).toBe('freebsd');
|
|
59
53
|
expect(p.arch).toBe('mips');
|
|
60
54
|
});
|
|
61
55
|
|
|
62
|
-
test('returns raw platform and architecture fields alongside mapped ones',
|
|
56
|
+
test('returns raw platform and architecture fields alongside mapped ones', () => {
|
|
63
57
|
mockPlatform('linux', 'x64');
|
|
64
|
-
const
|
|
65
|
-
const p = fn();
|
|
58
|
+
const p = getCurrentPlatform();
|
|
66
59
|
expect(p.platform).toBe('linux');
|
|
67
60
|
expect(p.architecture).toBe('x64');
|
|
68
61
|
});
|