File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ import path from 'path'
77import { LspVersion } from '../types'
88import { fs } from '../../../shared/fs/fs'
99import { partition } from '../../../shared/utilities/tsUtils'
10- import { sort } from 'semver'
10+ import { parse , sort } from 'semver'
1111
12- async function getDownloadedVersions ( installLocation : string ) {
13- return ( await fs . readdir ( installLocation ) ) . map ( ( [ f , _ ] , __ ) => f )
12+ export async function getDownloadedVersions ( installLocation : string ) {
13+ return ( await fs . readdir ( installLocation ) ) . filter ( ( x ) => parse ( x [ 0 ] ) !== null ) . map ( ( [ f , _ ] , __ ) => f )
1414}
1515
1616function isDelisted ( manifestVersions : LspVersion [ ] , targetVersion : string ) : boolean {
Original file line number Diff line number Diff line change 44 */
55
66import { Uri } from 'vscode'
7- import { cleanLspDownloads , fs } from '../../../../shared'
7+ import { cleanLspDownloads , fs , getDownloadedVersions } from '../../../../shared'
88import { createTestWorkspaceFolder } from '../../../testUtil'
99import path from 'path'
1010import assert from 'assert'
@@ -101,4 +101,16 @@ describe('cleanLSPDownloads', function () {
101101 assert . strictEqual ( result . length , 0 )
102102 assert . strictEqual ( deleted . length , 1 )
103103 } )
104+
105+ it ( 'ignores invalid versions' , async function ( ) {
106+ await fakeInstallVersions ( [ '1.0.0' , '.DS_STORE' ] , installationDir . fsPath )
107+ const deleted = await cleanLspDownloads (
108+ [ { serverVersion : '1.0.0' , isDelisted : true , targets : [ ] } ] ,
109+ installationDir . fsPath
110+ )
111+
112+ const result = await getDownloadedVersions ( installationDir . fsPath )
113+ assert . strictEqual ( result . length , 0 )
114+ assert . strictEqual ( deleted . length , 1 )
115+ } )
104116} )
You can’t perform that action at this time.
0 commit comments