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

Reverted "Refactored remaining function in package-json lib to use async-await"

- this reverts commit 2be01e7cbd.
- reverting until I can figure out why the tests are broken
This commit is contained in:
Daniel Lockyer 2020-11-25 10:57:55 +00:00
parent 2be01e7cbd
commit 7f09052ba1

View file

@ -150,10 +150,10 @@ module.exports = class PackageJson {
} }
} }
async readPackages(packagePath) { readPackages(packagePath) {
const dirContents = await fs.readdir(packagePath); const self = this;
const packageNames = dirContents return Promise.resolve(fs.readdir(packagePath))
.filter(function (packageName) { .filter(function (packageName) {
// Filter out things which are not packages by regex // Filter out things which are not packages by regex
if (packageName.match(notAPackageRegex)) { if (packageName.match(notAPackageRegex)) {
@ -163,14 +163,13 @@ module.exports = class PackageJson {
return fs.stat(join(packagePath, packageName)).then(function (stat) { return fs.stat(join(packagePath, packageName)).then(function (stat) {
return stat.isDirectory(); return stat.isDirectory();
}); });
}); })
.map(function readPackageJson(packageName) {
const packages = await Promise.all(packageNames
.map((packageName) => {
const absolutePath = join(packagePath, packageName); const absolutePath = join(packagePath, packageName);
return this.processPackage(absolutePath, packageName); return self.processPackage(absolutePath, packageName);
})); })
.then(function (packages) {
return _.keyBy(packages, 'name'); return _.keyBy(packages, 'name');
});
} }
}; };