Skip to content

Commit e7bf0af

Browse files
committed
clean up handling on optional args
1 parent 9cd4544 commit e7bf0af

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,32 @@ export const supportedLspServerVersions = '0.1.32'
1818
export const lspWorkspaceName = 'AmazonQ-Workspace'
1919

2020
export class WorkspaceLSPResolver implements LspResolver {
21+
private readonly versionRange: Range
22+
private readonly shouldCleanUp: boolean
2123
public constructor(
22-
private readonly options = {
23-
versionRange: new Range(supportedLspServerVersions),
24-
cleanUp: true,
25-
}
26-
) {}
24+
options?: Partial<{
25+
versionRange: Range
26+
cleanUp: boolean
27+
}>
28+
) {
29+
this.versionRange = options?.versionRange ?? new Range(supportedLspServerVersions)
30+
this.shouldCleanUp = options?.cleanUp ?? true
31+
}
2732

2833
async resolve(): Promise<LspResolution> {
2934
const manifest = await new ManifestResolver(manifestUrl, lspWorkspaceName).resolve()
3035
const installationResult = await new LanguageServerResolver(
3136
manifest,
3237
lspWorkspaceName,
33-
this.options.versionRange
38+
this.versionRange
3439
).resolve()
3540

3641
const nodeName =
3742
process.platform === 'win32' ? getNodeExecutableName() : `node-${process.platform}-${process.arch}`
3843
const nodePath = path.join(installationResult.assetDirectory, nodeName)
3944
await fs.chmod(nodePath, 0o755)
4045

41-
if (this.options.cleanUp) {
46+
if (this.shouldCleanUp) {
4247
await this.cleanUp(manifest.versions, path.dirname(installationResult.assetDirectory))
4348
}
4449
return {

0 commit comments

Comments
 (0)