File tree 1 file changed +21
-1
lines changed 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,7 @@ export class VulncheckProvider {
223
223
}
224
224
225
225
private async runInternal ( goCtx : GoExtensionContext ) {
226
- const pick = await vscode . window . showQuickPick ( [ 'Current Package' , 'Workspace' ] ) ;
226
+ const pick = await vscode . window . showQuickPick ( [ 'Current Package' , 'Current Module' , ' Workspace'] ) ;
227
227
let dir , pattern : string ;
228
228
const document = vscode . window . activeTextEditor ?. document ;
229
229
switch ( pick ) {
@@ -241,6 +241,14 @@ export class VulncheckProvider {
241
241
dir = path . dirname ( document . fileName ) ;
242
242
pattern = '.' ;
243
243
break ;
244
+ case 'Current Module' :
245
+ dir = await moduleDir ( document ) ;
246
+ if ( ! dir ) {
247
+ vscode . window . showErrorMessage ( 'vulncheck error: no current module' ) ;
248
+ return ;
249
+ }
250
+ pattern = './...' ;
251
+ break ;
244
252
case 'Workspace' :
245
253
dir = await this . activeDir ( ) ;
246
254
pattern = './...' ;
@@ -308,6 +316,18 @@ export class VulncheckProvider {
308
316
}
309
317
}
310
318
319
+ async function moduleDir ( document : vscode . TextDocument | undefined ) {
320
+ const docDir = document && document . fileName && path . dirname ( document . fileName ) ;
321
+ if ( ! docDir ) {
322
+ return ;
323
+ }
324
+ const modFile = await getGoModFile ( vscode . Uri . file ( docDir ) ) ;
325
+ if ( ! modFile ) {
326
+ return ;
327
+ }
328
+ return path . dirname ( modFile ) ;
329
+ }
330
+
311
331
// run `gopls vulncheck`.
312
332
export async function vulncheck (
313
333
goCtx : GoExtensionContext ,
You can’t perform that action at this time.
0 commit comments