From 7f09052ba18499ea41f5763f21bd31ba69a05369 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Wed, 25 Nov 2020 10:57:55 +0000 Subject: [PATCH] Reverted "Refactored remaining function in package-json lib to use async-await" - this reverts commit 2be01e7cbd7c7670256ad58947dbeae79bb0fd2c. - reverting until I can figure out why the tests are broken --- ghost/package-json/lib/package-json.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ghost/package-json/lib/package-json.js b/ghost/package-json/lib/package-json.js index e417e43907..0b3045fd77 100644 --- a/ghost/package-json/lib/package-json.js +++ b/ghost/package-json/lib/package-json.js @@ -150,10 +150,10 @@ module.exports = class PackageJson { } } - async readPackages(packagePath) { - const dirContents = await fs.readdir(packagePath); + readPackages(packagePath) { + const self = this; - const packageNames = dirContents + return Promise.resolve(fs.readdir(packagePath)) .filter(function (packageName) { // Filter out things which are not packages by regex if (packageName.match(notAPackageRegex)) { @@ -163,14 +163,13 @@ module.exports = class PackageJson { return fs.stat(join(packagePath, packageName)).then(function (stat) { return stat.isDirectory(); }); - }); - - const packages = await Promise.all(packageNames - .map((packageName) => { + }) + .map(function readPackageJson(packageName) { const absolutePath = join(packagePath, packageName); - return this.processPackage(absolutePath, packageName); - })); - - return _.keyBy(packages, 'name'); + return self.processPackage(absolutePath, packageName); + }) + .then(function (packages) { + return _.keyBy(packages, 'name'); + }); } };