-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change cache clean to manual command
Cleaning the cache could take a few seconds, and it prevented other extension commands from running while it was working.
- Loading branch information
1 parent
588a7ab
commit 8e9c4cc
Showing
5 changed files
with
47 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import cacache = require('cacache'); | ||
import * as vscode from 'vscode'; | ||
import * as nls from 'vscode-nls'; | ||
|
||
import { Command } from '../commandManager'; | ||
import { getLogger } from '../logger'; | ||
import { getNpmCacheDir } from '../util'; | ||
|
||
const localize = nls.loadMessageBundle(); | ||
|
||
/** | ||
* Opens extensions.private.json to the "registries" element. | ||
*/ | ||
export class CleanCacheCommand implements Command { | ||
public readonly id = 'privateExtensions.cleanCache'; | ||
|
||
public async execute() { | ||
const cache = getNpmCacheDir(); | ||
|
||
if (!cache) { | ||
vscode.window.showErrorMessage(localize('cache.missing', 'NPM cache is missing.')); | ||
return; | ||
} | ||
|
||
vscode.window.withProgress( | ||
{ | ||
title: localize('cleaning.npm.cache', 'Cleaning NPM cache.'), | ||
location: vscode.ProgressLocation.Notification, | ||
}, | ||
async () => { | ||
const stats = await cacache.verify(cache); | ||
getLogger().log(`Cleaned NPM cache: ${JSON.stringify(stats)}`); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters