From 8e61766bd806b7985f5270e75ec4610242665d0c Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 22 Apr 2025 09:26:46 +0200 Subject: [PATCH] Added is windows utility --- .../src/suite/followLink.vscode.test.ts | 11 +++++------ .../cursorless-vscode/src/InstallationDependencies.ts | 3 ++- packages/node-common/src/index.ts | 3 ++- packages/node-common/src/isWindows.ts | 5 +++++ packages/test-harness/src/launchNeovimAndRunTests.ts | 4 ++-- packages/test-harness/src/launchVscodeAndRunTests.ts | 7 +++---- 6 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 packages/node-common/src/isWindows.ts diff --git a/packages/cursorless-vscode-e2e/src/suite/followLink.vscode.test.ts b/packages/cursorless-vscode-e2e/src/suite/followLink.vscode.test.ts index 27074091f4..eb094df21d 100644 --- a/packages/cursorless-vscode-e2e/src/suite/followLink.vscode.test.ts +++ b/packages/cursorless-vscode-e2e/src/suite/followLink.vscode.test.ts @@ -1,10 +1,8 @@ -import { openNewEditor } from "@cursorless/vscode-common"; +import { getFixturePath, isWindows } from "@cursorless/node-common"; +import { openNewEditor, runCursorlessCommand } from "@cursorless/vscode-common"; import * as assert from "assert"; -import * as os from "os"; import * as vscode from "vscode"; import { endToEndTestSetup } from "../endToEndTestSetup"; -import { runCursorlessCommand } from "@cursorless/vscode-common"; -import { getFixturePath } from "@cursorless/node-common"; suite("followLink", async function () { endToEndTestSetup(this); @@ -45,8 +43,9 @@ async function followDefinition() { async function followLink() { const filename = getFixturePath("helloWorld.txt"); - const linkTextContent = - os.platform() === "win32" ? `file:///${filename}` : `file://${filename}`; + const linkTextContent = isWindows() + ? `file:///${filename}` + : `file://${filename}`; await openNewEditor(linkTextContent); await runCursorlessCommand({ diff --git a/packages/cursorless-vscode/src/InstallationDependencies.ts b/packages/cursorless-vscode/src/InstallationDependencies.ts index d669110177..8dd798332a 100644 --- a/packages/cursorless-vscode/src/InstallationDependencies.ts +++ b/packages/cursorless-vscode/src/InstallationDependencies.ts @@ -1,3 +1,4 @@ +import { isWindows } from "@cursorless/node-common"; import { COMMAND_SERVER_EXTENSION_ID } from "@cursorless/vscode-common"; import { globSync } from "glob"; import * as fs from "node:fs"; @@ -142,7 +143,7 @@ function commandServerInstalled() { } function getTalonHomePath() { - return os.platform() === "win32" + return isWindows() ? `${os.homedir()}\\AppData\\Roaming\\talon` : `${os.homedir()}/.talon`; } diff --git a/packages/node-common/src/index.ts b/packages/node-common/src/index.ts index 9159de2a75..fcc8a82367 100644 --- a/packages/node-common/src/index.ts +++ b/packages/node-common/src/index.ts @@ -5,8 +5,9 @@ export * from "./FileSystemTutorialContentProvider"; export * from "./getCursorlessRepoRoot"; export * from "./getFixturePaths"; export * from "./getScopeTestPathsRecursively"; +export * from "./isWindows"; +export * from "./loadFixture"; export * from "./nodeGetRunMode"; export * from "./runRecordedTest"; export * from "./walkAsync"; export * from "./walkSync"; -export * from "./loadFixture"; diff --git a/packages/node-common/src/isWindows.ts b/packages/node-common/src/isWindows.ts new file mode 100644 index 0000000000..e267adb96f --- /dev/null +++ b/packages/node-common/src/isWindows.ts @@ -0,0 +1,5 @@ +import * as os from "node:os"; + +export function isWindows() { + return os.platform() === "win32"; +} diff --git a/packages/test-harness/src/launchNeovimAndRunTests.ts b/packages/test-harness/src/launchNeovimAndRunTests.ts index d5e9901143..90ac2fc75e 100644 --- a/packages/test-harness/src/launchNeovimAndRunTests.ts +++ b/packages/test-harness/src/launchNeovimAndRunTests.ts @@ -1,5 +1,5 @@ import { getEnvironmentVariableStrict } from "@cursorless/common"; -import { getCursorlessRepoRoot } from "@cursorless/node-common"; +import { getCursorlessRepoRoot, isWindows } from "@cursorless/node-common"; import * as cp from "child_process"; import { copyFile, mkdirSync, readdirSync } from "fs"; import process from "node:process"; @@ -55,7 +55,7 @@ export async function launchNeovimAndRunTests() { // testing normal nvim startup //https://stackoverflow.com/questions/3025615/is-there-a-vim-runtime-log // if (process.platform === "darwin" || process.platform === "win32") { - if (process.platform === "win32") { + if (isWindows()) { // const { status, signal, error } = cp.spawnSync(cli, [`-V9`], { const { status, signal, error } = cp.spawnSync(cli, [`-V25`], { encoding: "utf-8", diff --git a/packages/test-harness/src/launchVscodeAndRunTests.ts b/packages/test-harness/src/launchVscodeAndRunTests.ts index ad2442788d..a62e992c0d 100644 --- a/packages/test-harness/src/launchVscodeAndRunTests.ts +++ b/packages/test-harness/src/launchVscodeAndRunTests.ts @@ -2,14 +2,13 @@ import { extensionDependencies, getEnvironmentVariableStrict, } from "@cursorless/common"; -import { getCursorlessRepoRoot } from "@cursorless/node-common"; +import { getCursorlessRepoRoot, isWindows } from "@cursorless/node-common"; import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath, runTests, } from "@vscode/test-electron"; import { sync } from "cross-spawn"; -import * as os from "node:os"; import * as path from "node:path"; /** @@ -41,7 +40,7 @@ export async function launchVscodeAndRunTests(extensionTestsPath: string) { const vscodeVersion = useLegacyVscode ? "1.82.0" - : os.platform() === "win32" + : isWindows() ? "stable" : "1.97.2"; const vscodeExecutablePath = await downloadAndUnzipVSCode(vscodeVersion); @@ -82,7 +81,7 @@ export async function launchVscodeAndRunTests(extensionTestsPath: string) { // hangs some of the time, so might be enough to get a crash dump when you // need it. launchArgs: - useLegacyVscode || os.platform() === "win32" + useLegacyVscode || isWindows() ? undefined : [`--crash-reporter-directory=${crashDir}`, `--logsPath=${logsDir}`], });