From 872436079a7e88bd871ed7927c7cf29d0dad2eac Mon Sep 17 00:00:00 2001 From: Kyle Cutler <67761731+kycutler@users.noreply.github.com> Date: Wed, 9 Apr 2025 18:25:28 +0000 Subject: [PATCH 1/2] Fix `TypeError` from trying to read directory --- src/extension/noConfigDebugInit.ts | 4 ++-- src/test/unittest/noConfigDebugInit.unit.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extension/noConfigDebugInit.ts b/src/extension/noConfigDebugInit.ts index 49bc506..428c478 100644 --- a/src/extension/noConfigDebugInit.ts +++ b/src/extension/noConfigDebugInit.ts @@ -87,7 +87,7 @@ export async function registerNoConfigDebug( ); // create file system watcher for the debuggerAdapterEndpointFolder for when the communication port is written - const fileSystemWatcher = createFileSystemWatcher(new RelativePattern(tempDirPath, '**/*')); + const fileSystemWatcher = createFileSystemWatcher(new RelativePattern(tempDirPath, '**/*.txt')); const fileCreationEvent = fileSystemWatcher.onDidCreate(async (uri) => { sendTelemetryEvent(EventName.DEBUG_SESSION_START, undefined, { trigger: 'noConfig' as TriggerType, @@ -95,13 +95,13 @@ export async function registerNoConfigDebug( const filePath = uri.fsPath; fs.readFile(filePath, (err, data) => { - const dataParse = data.toString(); if (err) { traceError(`Error reading debuggerAdapterEndpoint.txt file: ${err}`); return; } try { // parse the client port + const dataParse = data.toString(); const jsonData = JSON.parse(dataParse); const clientPort = jsonData.client?.port; traceVerbose(`Parsed client port: ${clientPort}`); diff --git a/src/test/unittest/noConfigDebugInit.unit.test.ts b/src/test/unittest/noConfigDebugInit.unit.test.ts index 47f3a9f..7763f72 100644 --- a/src/test/unittest/noConfigDebugInit.unit.test.ts +++ b/src/test/unittest/noConfigDebugInit.unit.test.ts @@ -99,7 +99,7 @@ suite('setup for no-config debug scenario', function () { // Assert sinon.assert.calledOnce(createFileSystemWatcherFunct); - const expectedPattern = new RelativePattern(path.join(os.tmpdir(), '.noConfigDebugAdapterEndpoints'), '**/*'); + const expectedPattern = new RelativePattern(path.join(os.tmpdir(), '.noConfigDebugAdapterEndpoints'), '**/*.txt'); sinon.assert.calledWith(createFileSystemWatcherFunct, expectedPattern); }); From e3f4970cdd37f1947ba35bdb85492d68e2512c51 Mon Sep 17 00:00:00 2001 From: Kyle Cutler <67761731+kycutler@users.noreply.github.com> Date: Wed, 9 Apr 2025 18:43:02 +0000 Subject: [PATCH 2/2] Fix lint issue --- src/test/unittest/noConfigDebugInit.unit.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/unittest/noConfigDebugInit.unit.test.ts b/src/test/unittest/noConfigDebugInit.unit.test.ts index 7763f72..a4f9c79 100644 --- a/src/test/unittest/noConfigDebugInit.unit.test.ts +++ b/src/test/unittest/noConfigDebugInit.unit.test.ts @@ -99,7 +99,10 @@ suite('setup for no-config debug scenario', function () { // Assert sinon.assert.calledOnce(createFileSystemWatcherFunct); - const expectedPattern = new RelativePattern(path.join(os.tmpdir(), '.noConfigDebugAdapterEndpoints'), '**/*.txt'); + const expectedPattern = new RelativePattern( + path.join(os.tmpdir(), '.noConfigDebugAdapterEndpoints'), + '**/*.txt', + ); sinon.assert.calledWith(createFileSystemWatcherFunct, expectedPattern); });