Skip to content

Commit 03df39b

Browse files
authored
Fix TypeError from trying to read directory (#692)
* Fix `TypeError` from trying to read directory * Fix lint issue
1 parent 020bd42 commit 03df39b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/extension/noConfigDebugInit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,21 @@ export async function registerNoConfigDebug(
8787
);
8888

8989
// create file system watcher for the debuggerAdapterEndpointFolder for when the communication port is written
90-
const fileSystemWatcher = createFileSystemWatcher(new RelativePattern(tempDirPath, '**/*'));
90+
const fileSystemWatcher = createFileSystemWatcher(new RelativePattern(tempDirPath, '**/*.txt'));
9191
const fileCreationEvent = fileSystemWatcher.onDidCreate(async (uri) => {
9292
sendTelemetryEvent(EventName.DEBUG_SESSION_START, undefined, {
9393
trigger: 'noConfig' as TriggerType,
9494
});
9595

9696
const filePath = uri.fsPath;
9797
fs.readFile(filePath, (err, data) => {
98-
const dataParse = data.toString();
9998
if (err) {
10099
traceError(`Error reading debuggerAdapterEndpoint.txt file: ${err}`);
101100
return;
102101
}
103102
try {
104103
// parse the client port
104+
const dataParse = data.toString();
105105
const jsonData = JSON.parse(dataParse);
106106
const clientPort = jsonData.client?.port;
107107
traceVerbose(`Parsed client port: ${clientPort}`);

src/test/unittest/noConfigDebugInit.unit.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ suite('setup for no-config debug scenario', function () {
9999

100100
// Assert
101101
sinon.assert.calledOnce(createFileSystemWatcherFunct);
102-
const expectedPattern = new RelativePattern(path.join(os.tmpdir(), '.noConfigDebugAdapterEndpoints'), '**/*');
102+
const expectedPattern = new RelativePattern(
103+
path.join(os.tmpdir(), '.noConfigDebugAdapterEndpoints'),
104+
'**/*.txt',
105+
);
103106
sinon.assert.calledWith(createFileSystemWatcherFunct, expectedPattern);
104107
});
105108

0 commit comments

Comments
 (0)