Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Listing pre-releases is now customizable from setting crates.listPreR…
Browse files Browse the repository at this point in the history
…eleases #10
  • Loading branch information
serayuzgur committed Jul 4, 2018
1 parent 5f997ae commit b08bef7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions src/toml/decorations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b08bef7

Please sign in to comment.