diff --git a/CHANGELOG.md b/CHANGELOG.md index fb7c551..34b662a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to the "crates" extension will be documented in this file. * Marketplace badges are linked to marketplace. [#13](https://github.com/serayuzgur/crates/issues/13). * Package json improved. * The up to date decorator (👍) is now customizable from setting crates.upToDateDecorator [#12](https://github.com/serayuzgur/crates/issues/12). +* Listing pre-releases is now customizable from setting crates.listPreReleases [#10](https://github.com/serayuzgur/crates/issues/10). ### 0.2.0 diff --git a/README.md b/README.md index 5b89c41..23801c8 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ Aims to be fast and simple. It is so **simple** that you do not need any configuration, but if you insist... -`crates.upToDateDecorator :` The text to show when dependency is up to date. Default is 👍. +`crates.upToDateDecorator`: The text to show when dependency is up to date. Default is 👍. +`crates.listPreReleases` : If true, pre-release versions will be listed in hover and at decoration. Default is false. ## Known Issues diff --git a/package.json b/package.json index aac23a8..89cd2e3 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,13 @@ "type": "string", "scope": "resource", "default": "👍", - "description": "The text to show when dependency is up to date. " + "description": "The text to show when dependency is up to date." + }, + "crates.listPreReleases": { + "type": "boolean", + "scope": "resource", + "default": false, + "description": "If true, pre-release versions will be listed in hover and at decoration." } } } diff --git a/src/toml/decorations.ts b/src/toml/decorations.ts index c1100fb..e854f21 100644 --- a/src/toml/decorations.ts +++ b/src/toml/decorations.ts @@ -94,15 +94,21 @@ export function dependencies( const options: DecorationOptions[] = []; const responses = Object.keys(dependencies).map((key: string) => { console.log("Fetching dependency: ", key); - const upToDateDecoratorConf = workspace - .getConfiguration("", editor.document.uri) - .get("crates.upToDateDecorator"); + const conf = workspace.getConfiguration("", editor.document.uri); + const upToDateDecoratorConf = conf.get("crates.upToDateDecorator"); - const upToDateDecorator = upToDateDecoratorConf ? upToDateDecoratorConf + "" : ""; + const upToDateDecorator = upToDateDecoratorConf + ? upToDateDecoratorConf + "" + : ""; + const listPreReleases = conf.get("crates.listPreReleases"); return versions(key) .then((json: any) => { const versions = json.versions.reduce((result: any[], item: any) => { - if (!item.yanked) { + const isPreRelease = + !listPreReleases && + (item.num.indexOf("-alpha") !== -1 || + item.num.indexOf("-beta") !== -1); + if (!item.yanked && !isPreRelease) { result.push(item.num); } return result;