Replaced Promise.map() with .all() in importer (#15616)

refs: https://github.com/TryGhost/Ghost/issues/14882

- Removing bluebird specific methods in favour of the Ghost sequence method so we can remove the bluebird dependency

Co-authored-by: Carol-Barno <cbarno@innovexsolutions.co.ke>
This commit is contained in:
Barno 2022-10-30 19:51:29 +03:00 committed by GitHub
parent 7df2b7625f
commit a24eb06179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -1,5 +1,4 @@
const _ = require('lodash');
const Promise = require('bluebird');
const path = require('path');
const config = require('../../../../shared/config');
const urlUtils = require('../../../../shared/url-utils');
@ -35,14 +34,14 @@ ImageHandler = {
return file;
});
return Promise.map(files, function (image) {
return Promise.all(files.map(function (image) {
return store.getUniqueFileName(image, image.targetDir).then(function (targetFilename) {
image.newPath = urlUtils.urlJoin('/', urlUtils.getSubdir(), urlUtils.STATIC_IMAGE_URL_PREFIX,
path.relative(config.getContentPath('images'), targetFilename));
return image;
});
});
}));
}
};

View File

@ -1,5 +1,4 @@
const _ = require('lodash');
const Promise = require('bluebird');
const storage = require('../../../adapters/storage');
let replaceImage;
let ImageImporter;
@ -66,11 +65,11 @@ ImageImporter = {
doImport: function (imageData) {
const store = storage.getStorage('images');
return Promise.map(imageData, function (image) {
return Promise.all(imageData.map(function (image) {
return store.save(image, image.targetDir).then(function (result) {
return {originalPath: image.originalPath, newPath: image.newPath, stored: result};
});
});
}));
}
};