Skip to content

Commit

Permalink
Add language server menu option for clearing cached packages
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Aug 20, 2024
1 parent 7bb3902 commit 8c6600f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/LanguageServerManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ describe('LanguageServerManager', () => {

describe('clearNpmPackageCache', () => {
it('clears the cache', async () => {
fsExtra.ensureFileSync(`${storageDir}/test.txt`);
fsExtra.ensureFileSync(`${storageDir}/packages/test.txt`);
expect(fsExtra.pathExistsSync(`${storageDir}/packages/test.txt`)).to.be.true;

await languageServerManager.clearNpmPackageCache();
Expand Down
4 changes: 2 additions & 2 deletions src/commands/ClearNpmPackageCacheCommand.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as vscode from 'vscode';
import type { LanguageServerManager } from '../LanguageServerManager';
import { VscodeCommand } from './VscodeCommand';

export class ClearNpmPackageCacheCommand {
public static commandName = 'extension.brightscript.clearNpmPackageCache';

public register(context: vscode.ExtensionContext, languageServerManager: LanguageServerManager) {
context.subscriptions.push(vscode.commands.registerCommand(ClearNpmPackageCacheCommand.commandName, async () => {
context.subscriptions.push(vscode.commands.registerCommand(VscodeCommand.clearNpmPackageCache, async () => {
await languageServerManager.clearNpmPackageCache();
}));
}
Expand Down
9 changes: 9 additions & 0 deletions src/commands/LanguageServerInfoCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as childProcess from 'child_process';
import { firstBy } from 'thenby';
import * as dayjs from 'dayjs';
import * as relativeTime from 'dayjs/plugin/relativeTime';
import { util } from '../util';

Check failure on line 10 in src/commands/LanguageServerInfoCommand.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

'util' is declared but its value is never read.

Check failure on line 10 in src/commands/LanguageServerInfoCommand.ts

View workflow job for this annotation

GitHub Actions / ci (macos-latest)

'util' is declared but its value is never read.
import { VscodeCommand } from './VscodeCommand';
dayjs.extend(relativeTime);

export class LanguageServerInfoCommand {
Expand All @@ -26,6 +28,13 @@ export class LanguageServerInfoCommand {
label: `View language server logs`,
description: ``,
command: this.focusLanguageServerOutputChannel.bind(this)
}, {
label: `Delete cached brighterscript versions`,
description: ``,
command: async () => {
await vscode.commands.executeCommand(VscodeCommand.clearNpmPackageCache);
await vscode.window.showInformationMessage('All cached brighterscript versions have been removed');
}
}];

let selection = await vscode.window.showQuickPick(commands, { placeHolder: `BrighterScript Project Info` });
Expand Down
3 changes: 2 additions & 1 deletion src/commands/VscodeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export enum VscodeCommand {
rokuAppOverlaysViewRemoveAllOverlays = 'extension.brightscript.rokuAppOverlaysView.removeAllOverlays',
rokuFileSystemViewRefresh = 'extension.brightscript.rokuFileSystemView.refresh',
disconnectFromDevice = 'extension.brightscript.disconnectFromDevice',
openSceneGraphInspectorInPanel = 'extension.brightscript.openSceneGraphInspectorInPanel'
openSceneGraphInspectorInPanel = 'extension.brightscript.openSceneGraphInspectorInPanel',
clearNpmPackageCache = 'extension.brightscript.clearNpmPackageCache'
}

0 comments on commit 8c6600f

Please sign in to comment.