Skip to content

Commit a40854c

Browse files
Added is windows utility (#2900)
1 parent 740f658 commit a40854c

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

packages/cursorless-vscode-e2e/src/suite/followLink.vscode.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { openNewEditor } from "@cursorless/vscode-common";
1+
import { getFixturePath, isWindows } from "@cursorless/node-common";
2+
import { openNewEditor, runCursorlessCommand } from "@cursorless/vscode-common";
23
import * as assert from "assert";
3-
import * as os from "os";
44
import * as vscode from "vscode";
55
import { endToEndTestSetup } from "../endToEndTestSetup";
6-
import { runCursorlessCommand } from "@cursorless/vscode-common";
7-
import { getFixturePath } from "@cursorless/node-common";
86

97
suite("followLink", async function () {
108
endToEndTestSetup(this);
@@ -45,8 +43,9 @@ async function followDefinition() {
4543

4644
async function followLink() {
4745
const filename = getFixturePath("helloWorld.txt");
48-
const linkTextContent =
49-
os.platform() === "win32" ? `file:///${filename}` : `file://${filename}`;
46+
const linkTextContent = isWindows()
47+
? `file:///${filename}`
48+
: `file://${filename}`;
5049
await openNewEditor(linkTextContent);
5150

5251
await runCursorlessCommand({

packages/cursorless-vscode/src/InstallationDependencies.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isWindows } from "@cursorless/node-common";
12
import { COMMAND_SERVER_EXTENSION_ID } from "@cursorless/vscode-common";
23
import { globSync } from "glob";
34
import * as fs from "node:fs";
@@ -142,7 +143,7 @@ function commandServerInstalled() {
142143
}
143144

144145
function getTalonHomePath() {
145-
return os.platform() === "win32"
146+
return isWindows()
146147
? `${os.homedir()}\\AppData\\Roaming\\talon`
147148
: `${os.homedir()}/.talon`;
148149
}

packages/node-common/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ export * from "./FileSystemTutorialContentProvider";
55
export * from "./getCursorlessRepoRoot";
66
export * from "./getFixturePaths";
77
export * from "./getScopeTestPathsRecursively";
8+
export * from "./isWindows";
9+
export * from "./loadFixture";
810
export * from "./nodeGetRunMode";
911
export * from "./runRecordedTest";
1012
export * from "./walkAsync";
1113
export * from "./walkSync";
12-
export * from "./loadFixture";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as os from "node:os";
2+
3+
export function isWindows() {
4+
return os.platform() === "win32";
5+
}

packages/test-harness/src/launchNeovimAndRunTests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getEnvironmentVariableStrict } from "@cursorless/common";
2-
import { getCursorlessRepoRoot } from "@cursorless/node-common";
2+
import { getCursorlessRepoRoot, isWindows } from "@cursorless/node-common";
33
import * as cp from "child_process";
44
import { copyFile, mkdirSync, readdirSync } from "fs";
55
import process from "node:process";
@@ -55,7 +55,7 @@ export async function launchNeovimAndRunTests() {
5555
// testing normal nvim startup
5656
//https://stackoverflow.com/questions/3025615/is-there-a-vim-runtime-log
5757
// if (process.platform === "darwin" || process.platform === "win32") {
58-
if (process.platform === "win32") {
58+
if (isWindows()) {
5959
// const { status, signal, error } = cp.spawnSync(cli, [`-V9`], {
6060
const { status, signal, error } = cp.spawnSync(cli, [`-V25`], {
6161
encoding: "utf-8",

packages/test-harness/src/launchVscodeAndRunTests.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import {
22
extensionDependencies,
33
getEnvironmentVariableStrict,
44
} from "@cursorless/common";
5-
import { getCursorlessRepoRoot } from "@cursorless/node-common";
5+
import { getCursorlessRepoRoot, isWindows } from "@cursorless/node-common";
66
import {
77
downloadAndUnzipVSCode,
88
resolveCliArgsFromVSCodeExecutablePath,
99
runTests,
1010
} from "@vscode/test-electron";
1111
import { sync } from "cross-spawn";
12-
import * as os from "node:os";
1312
import * as path from "node:path";
1413

1514
/**
@@ -78,7 +77,7 @@ export async function launchVscodeAndRunTests(extensionTestsPath: string) {
7877
// hangs some of the time, so might be enough to get a crash dump when you
7978
// need it.
8079
launchArgs:
81-
useLegacyVscode || os.platform() === "win32"
80+
useLegacyVscode || isWindows()
8281
? undefined
8382
: [`--crash-reporter-directory=${crashDir}`, `--logsPath=${logsDir}`],
8483
});

0 commit comments

Comments
 (0)