refactor: remove util.promisify calls

This commit is contained in:
Barış Soner Uşaklı
2020-08-14 00:05:03 -04:00
parent 45c8de129c
commit 0189945996
18 changed files with 50 additions and 108 deletions

View File

@@ -1,7 +1,6 @@
'use strict';
const fs = require('fs');
const util = require('util');
const path = require('path');
const winston = require('winston');
@@ -12,9 +11,6 @@ const Data = module.exports;
const basePath = path.join(__dirname, '../../');
const readFileAsync = util.promisify(fs.readFile);
const statAsync = util.promisify(fs.stat);
Data.getPluginPaths = async function () {
let plugins = await db.getSortedSetRange('plugins:active', 0, -1);
plugins = plugins.filter(plugin => plugin && typeof plugin === 'string')
@@ -26,8 +22,8 @@ Data.getPluginPaths = async function () {
Data.loadPluginInfo = async function (pluginPath) {
const [packageJson, pluginJson] = await Promise.all([
readFileAsync(path.join(pluginPath, 'package.json'), 'utf8'),
readFileAsync(path.join(pluginPath, 'plugin.json'), 'utf8'),
fs.promises.readFile(path.join(pluginPath, 'package.json'), 'utf8'),
fs.promises.readFile(path.join(pluginPath, 'plugin.json'), 'utf8'),
]);
let pluginData;
@@ -96,7 +92,7 @@ Data.getStaticDirectories = async function (pluginData) {
const dirPath = path.join(pluginData.path, pluginData.staticDirs[route]);
try {
const stats = await statAsync(dirPath);
const stats = await fs.promises.stat(dirPath);
if (!stats.isDirectory()) {
winston.warn('[plugins/' + pluginData.id + '] Mapped path \'' +
route + ' => ' + dirPath + '\' is not a directory.');