Skip to content

Commit bace7ca

Browse files
committed
refactor: rename cleanup function and move test file
1 parent 88db689 commit bace7ca

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

packages/core/src/amazonq/lsp/workspaceInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { LanguageServerResolver } from '../../shared/lsp/lspResolver'
1010
import { Range } from 'semver'
1111
import { getNodeExecutableName } from '../../shared/lsp/utils/platform'
1212
import { fs } from '../../shared/fs/fs'
13-
import { cleanUpLSPDownloads } from '../../shared'
13+
import { cleanLspDownloads } from '../../shared'
1414

1515
const manifestUrl = 'https://aws-toolkit-language-servers.amazonaws.com/q-context/manifest.json'
1616
// this LSP client in Q extension is only going to work with these LSP server versions
@@ -31,7 +31,7 @@ export class WorkspaceLSPResolver implements LspResolver {
3131
const nodePath = path.join(installationResult.assetDirectory, nodeName)
3232
await fs.chmod(nodePath, 0o755)
3333

34-
await cleanUpLSPDownloads(manifest.versions, path.basename(installationResult.assetDirectory))
34+
await cleanLspDownloads(manifest.versions, path.basename(installationResult.assetDirectory))
3535
return {
3636
...installationResult,
3737
resourcePaths: {

packages/core/src/shared/lsp/utils/cleanup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function isDelisted(manifestVersions: LspVersion[], targetVersion: string): bool
2222
* @param manifest
2323
* @param downloadDirectory
2424
*/
25-
export async function cleanUpLSPDownloads(manifestVersions: LspVersion[], downloadDirectory: string): Promise<void> {
25+
export async function cleanLspDownloads(manifestVersions: LspVersion[], downloadDirectory: string): Promise<void> {
2626
const downloadedVersions = await getDownloadedVersions(downloadDirectory)
2727
const [delistedVersions, remainingVersions] = partition(downloadedVersions, (v: string) =>
2828
isDelisted(manifestVersions, v)

packages/core/src/test/amazonq/lsp/util.test.ts renamed to packages/core/src/test/lsp/util/cleanup.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { Uri } from 'vscode'
7-
import { cleanUpLSPDownloads, fs } from '../../../shared'
7+
import { cleanLspDownloads, fs } from '../../../shared'
88
import { createTestWorkspaceFolder } from '../../testUtil'
99
import path from 'path'
1010
import assert from 'assert'
@@ -21,7 +21,7 @@ async function fakeInstallVersions(versions: string[], installationDir: string):
2121
}
2222
}
2323

24-
describe('cleanUpLSPDownloads', function () {
24+
describe('cleanLSPDownloads', function () {
2525
let installationDir: Uri
2626

2727
before(async function () {
@@ -41,7 +41,7 @@ describe('cleanUpLSPDownloads', function () {
4141

4242
it('keeps two newest versions', async function () {
4343
await fakeInstallVersions(['1.0.0', '1.0.1', '1.1.1', '2.1.1'], installationDir.fsPath)
44-
await cleanUpLSPDownloads([], installationDir.fsPath)
44+
await cleanLspDownloads([], installationDir.fsPath)
4545

4646
const result = (await fs.readdir(installationDir.fsPath)).map(([filename, _filetype], _index) => filename)
4747
assert.strictEqual(result.length, 2)
@@ -51,7 +51,7 @@ describe('cleanUpLSPDownloads', function () {
5151

5252
it('deletes delisted versions', async function () {
5353
await fakeInstallVersions(['1.0.0', '1.0.1', '1.1.1', '2.1.1'], installationDir.fsPath)
54-
await cleanUpLSPDownloads([{ serverVersion: '1.1.1', isDelisted: true, targets: [] }], installationDir.fsPath)
54+
await cleanLspDownloads([{ serverVersion: '1.1.1', isDelisted: true, targets: [] }], installationDir.fsPath)
5555

5656
const result = (await fs.readdir(installationDir.fsPath)).map(([filename, _filetype], _index) => filename)
5757
assert.strictEqual(result.length, 2)
@@ -61,7 +61,7 @@ describe('cleanUpLSPDownloads', function () {
6161

6262
it('handles case where less than 2 versions are not delisted', async function () {
6363
await fakeInstallVersions(['1.0.0', '1.0.1', '1.1.1', '2.1.1'], installationDir.fsPath)
64-
await cleanUpLSPDownloads(
64+
await cleanLspDownloads(
6565
[
6666
{ serverVersion: '1.1.1', isDelisted: true, targets: [] },
6767
{ serverVersion: '2.1.1', isDelisted: true, targets: [] },
@@ -77,15 +77,15 @@ describe('cleanUpLSPDownloads', function () {
7777

7878
it('handles case where less than 2 versions exist', async function () {
7979
await fakeInstallVersions(['1.0.0'], installationDir.fsPath)
80-
await cleanUpLSPDownloads([], installationDir.fsPath)
80+
await cleanLspDownloads([], installationDir.fsPath)
8181

8282
const result = (await fs.readdir(installationDir.fsPath)).map(([filename, _filetype], _index) => filename)
8383
assert.strictEqual(result.length, 1)
8484
})
8585

8686
it('does not install delisted version when no other option exists', async function () {
8787
await fakeInstallVersions(['1.0.0'], installationDir.fsPath)
88-
await cleanUpLSPDownloads([{ serverVersion: '1.0.0', isDelisted: true, targets: [] }], installationDir.fsPath)
88+
await cleanLspDownloads([{ serverVersion: '1.0.0', isDelisted: true, targets: [] }], installationDir.fsPath)
8989

9090
const result = (await fs.readdir(installationDir.fsPath)).map(([filename, _filetype], _index) => filename)
9191
assert.strictEqual(result.length, 0)

0 commit comments

Comments
 (0)