From 4a1d7f205ccb94928ec5728def50604c36aed22c Mon Sep 17 00:00:00 2001 From: SoonIter Date: Wed, 7 Feb 2024 18:33:03 +0800 Subject: [PATCH] fix(test): try to fix windows url --- src/extension.ts | 2 +- tests/fileModifications.test.ts | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 3c9bc985..25fbbf93 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -264,7 +264,7 @@ async function watchEditsToRestartLanguageClient(context: ExtensionContext) { try { // get the absolute URI to this relative path let configUri = Uri.file( - workspace.workspaceFolders![0].uri.fsPath + '/' + configPath + path.join(workspace.workspaceFolders![0].uri.fsPath, configPath) ) // read the config file let configText = await workspace.fs.readFile(configUri) diff --git a/tests/fileModifications.test.ts b/tests/fileModifications.test.ts index 7f7039ae..c126ce12 100644 --- a/tests/fileModifications.test.ts +++ b/tests/fileModifications.test.ts @@ -1,5 +1,6 @@ import * as vscode from 'vscode' import * as yaml from 'js-yaml' +import path from 'path' import { getDocUri, @@ -16,8 +17,11 @@ const diagnosticss = getExpectedDiagnosticss() async function writeNewRule() { let vscodeuri = vscode.Uri.file( - vscode.workspace.workspaceFolders![0].uri.fsPath + - '/rules/no-math-random.yml' + path.join( + vscode.workspace.workspaceFolders![0].uri.fsPath, + 'rules', + 'no-math-random.yml' + ) ) await vscode.workspace.fs.writeFile( vscodeuri, @@ -34,14 +38,17 @@ note: no Math.random()`) } async function deleteNewRule() { let vscodeuri = vscode.Uri.file( - vscode.workspace.workspaceFolders![0].uri.fsPath + - '/rules/no-math-random.yml' + path.join( + vscode.workspace.workspaceFolders![0].uri.fsPath, + 'rules', + 'no-math-random.yml' + ) ) await vscode.workspace.fs.delete(vscodeuri) } async function setRuleDirs(newRuleDirs: string[]) { let vscodeuri = vscode.Uri.file( - vscode.workspace.workspaceFolders![0].uri.fsPath + '/sgconfig.yml' + path.join(vscode.workspace.workspaceFolders![0].uri.fsPath, 'sgconfig.yml') ) let content = await vscode.workspace.fs.readFile(vscodeuri) let configText = new TextDecoder().decode(content)