Skip to content

Commit

Permalink
Merge pull request #878 from codingtwinky/877
Browse files Browse the repository at this point in the history
Fix cache value being promise in ubuntu
  • Loading branch information
jung-kim authored Feb 28, 2017
2 parents c137600 + 3f0b03d commit 4447bc2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
Use the following format for additions: ` - VERSION: [feature/patch (if applicable)] Short description of change. Links to relevant issues/PRs.`

- 1.1.9: Fix around ubuntu's inability to cache promises. [#877](https://github.com/FredrikNoren/ungit/pull/878)
- 1.1.8:
- Realtime text diff via invalidate diff on directory change [#867](https://github.com/FredrikNoren/ungit/pull/867)
- Promisify `./source/utils/cache.js` [#870](https://github.com/FredrikNoren/ungit/pull/870)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ungit",
"author": "Fredrik Norén <[email protected]>",
"description": "Git made easy",
"version": "1.1.8",
"version": "1.1.9",
"ungitPluginApiVersion": "0.2.0",
"scripts": {
"start": "node ./bin/ungit",
Expand Down
7 changes: 5 additions & 2 deletions source/utils/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ cache.resolveFunc = (key) => {
.catch({ errorcode: "ENOTFOUND" }, (e) => {
if (!funcMap[key]) throw e; // func associated with key is not found, throw not found error
const result = funcMap[key].func(); // func is found, resolve, set with TTL and return result
return cache.setAsync(key, result, funcMap[key].ttl)
.then(() => { return result });
return (result.then ? result : Bluebird.resolve(result))
.then((r) => {
return cache.setAsync(key, r, funcMap[key].ttl)
.then(() => { return r; })
});
});
}

Expand Down

0 comments on commit 4447bc2

Please sign in to comment.