Skip to content

Commit

Permalink
refactor: remove bluebird dep
Browse files Browse the repository at this point in the history
Also, update eslintrc to support arrow notation.

Ref: TryGhost/Ghost#14882
  • Loading branch information
markstos committed Sep 3, 2023
1 parent 0a9f00b commit 1ada47b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"node": true
},

"parserOptions": {
"ecmaVersion": 2022,
},

"globals": {
"describe": true,
"beforeEach": true,
Expand Down
21 changes: 14 additions & 7 deletions lib/resolver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

var Promise = require('bluebird');

var generateId = require('./generate-id');

var ID_LENGTH = 8;
Expand All @@ -28,12 +26,21 @@ function resolve(cache, fn, context) {
return id;
}

// cache is an object where the keys are cache keys and values are promises. See above.
function done(cache, callback) {
Promise.props(cache).then(function(values) {
callback(null, values);
}).catch(function(error) {
callback(error);
});
return Promise.all(Object.values(cache)).then((values) => {
const resolvedCache = {};
const keys = Object.keys(cache);
if (typeof values != 'undefined') {
values.forEach((value, index) => {
resolvedCache[keys[index]] = value;
});
return callback(null, resolvedCache);
}
return callback(null, {});
}).catch((error) => {
return callback(error);
})
}

function hasResolvers(text) {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
"supertest": "6.3.3"
},
"dependencies": {
"bluebird": "^3.5.3",
"handlebars": "^4.7.7",
"lodash": "^4.17.21",
"readdirp": "^3.6.0"
},
"optionalDependencies": {
"js-beautify": "^1.13.11"
},
"engines": {
"node": ">=16"
}
}
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,6 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==

bluebird@^3.5.3:
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==

[email protected]:
version "1.20.1"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.1.tgz#b1812a8912c195cd371a3ee5e66faa2338a5c668"
Expand Down

0 comments on commit 1ada47b

Please sign in to comment.