0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Removed global.Promise override (#12182)

closed #11943 

* Remove global.Promise
* Fix brute-knex bluebird error.
* Fix api-acceptance tests.
* Fix unit tests
This commit is contained in:
Kukhyeon Heo 2020-11-04 19:55:47 +09:00 committed by GitHub
parent e3e15646eb
commit 504509bb67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 9 additions and 16 deletions

View file

@ -1,3 +1,4 @@
const Promise = require('bluebird');
const moment = require('moment-timezone');
const fs = require('fs-extra');
const path = require('path');

View file

@ -25,7 +25,7 @@ module.exports = function ensureSettingsFiles(knownSettings) {
const defaultFileName = `default-${fileName}`;
const filePath = path.join(contentPath, fileName);
return fs.readFile(filePath, 'utf8')
return Promise.resolve(fs.readFile(filePath, 'utf8'))
.catch({code: 'ENOENT'}, () => {
const defaultFilePath = path.join(defaultSettingsPath, defaultFileName);
// CASE: file doesn't exist, copy it from our defaults

View file

@ -1,3 +1,4 @@
const Promise = require('bluebird');
const storage = require('../../adapters/storage');
module.exports = {

View file

@ -1,3 +1,4 @@
const Promise = require('bluebird');
const debug = require('ghost-ignition').debug('api:canary:utils:serializers:output:roles');
const canThis = require('../../../../../services/permissions').canThis;

View file

@ -12,7 +12,7 @@ const exporter = require('../exporter');
const writeExportFile = function writeExportFile(exportResult) {
const filename = path.resolve(urlUtils.urlJoin(config.get('paths').contentPath, 'data', exportResult.filename));
return fs.writeFile(filename, JSON.stringify(exportResult.data)).return(filename);
return Promise.resolve(fs.writeFile(filename, JSON.stringify(exportResult.data))).return(filename);
};
const readBackup = async (filename) => {

View file

@ -60,7 +60,7 @@ const readPackage = function readPackage(packagePath, packageName) {
};
const readPackages = function readPackages(packagePath) {
return fs.readdir(packagePath)
return Promise.resolve(fs.readdir(packagePath))
.filter(function (packageName) {
// Filter out things which are not packages by regex
if (packageName.match(notAPackageRegex)) {

View file

@ -12,7 +12,7 @@ module.exports.lookup = function lookup(userData, timeout) {
return Promise.resolve();
}
return request('https:' + gravatarUrl + '&d=404&r=x', {timeout: timeout || 2 * 1000})
return Promise.resolve(request('https:' + gravatarUrl + '&d=404&r=x', {timeout: timeout || 2 * 1000}))
.then(function () {
gravatarUrl += '&d=mm&r=x';

View file

@ -23,8 +23,3 @@ const {extract, hasProvider} = require('oembed-parser'); // eslint-disable-line
* - be careful when you work with date operations, therefor always wrap a date into moment
*/
moment.tz.setDefault('UTC');
/**
* https://github.com/TryGhost/Ghost/issues/9064
*/
global.Promise = require('bluebird');

View file

@ -3,11 +3,6 @@ const sinon = require('sinon');
const utils = require('../../../../core/server/data/migrations/utils');
// Get access to the core Promise constructor
// as global.Promise is overidden by Ghost
// https://github.com/TryGhost/Ghost/issues/9064
const Promise = (async () => {})().constructor;
class Deferred {
constructor() {
this.promise = new Promise((resolve, reject) => {

View file

@ -20,8 +20,8 @@ describe('Content API Key Auth', function () {
this.fakeApiKey = fakeApiKey;
this.apiKeyStub = sinon.stub(models.ApiKey, 'findOne');
this.apiKeyStub.returns(new Promise.resolve());
this.apiKeyStub.withArgs({secret: fakeApiKey.secret}).returns(new Promise.resolve(fakeApiKey));
this.apiKeyStub.returns(Promise.resolve());
this.apiKeyStub.withArgs({secret: fakeApiKey.secret}).returns(Promise.resolve(fakeApiKey));
});
afterEach(function () {