mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 15:06:38 +02:00
refactor: remove util.promisify calls
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const util = require('util');
|
||||
const readFileAsync = util.promisify(fs.readFile);
|
||||
|
||||
const file = require('../../file');
|
||||
|
||||
@@ -17,7 +15,7 @@ themesController.get = async function (req, res, next) {
|
||||
|
||||
let themeConfig;
|
||||
try {
|
||||
themeConfig = await readFileAsync(themeConfigPath, 'utf8');
|
||||
themeConfig = await fs.promises.readFile(themeConfigPath, 'utf8');
|
||||
themeConfig = JSON.parse(themeConfig);
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
|
||||
@@ -4,9 +4,6 @@ const path = require('path');
|
||||
const nconf = require('nconf');
|
||||
const mime = require('mime');
|
||||
const fs = require('fs');
|
||||
const util = require('util');
|
||||
const readdirAsync = util.promisify(fs.readdir);
|
||||
const statAsync = util.promisify(fs.stat);
|
||||
|
||||
const meta = require('../../meta');
|
||||
const posts = require('../../posts');
|
||||
@@ -27,7 +24,7 @@ uploadsController.get = async function (req, res, next) {
|
||||
const itemsPerPage = 20;
|
||||
const page = parseInt(req.query.page, 10) || 1;
|
||||
try {
|
||||
let files = await readdirAsync(currentFolder);
|
||||
let files = await fs.promises.readdir(currentFolder);
|
||||
files = files.filter(filename => filename !== '.gitignore');
|
||||
const itemCount = files.length;
|
||||
var start = Math.max(0, (page - 1) * itemsPerPage);
|
||||
@@ -91,10 +88,10 @@ async function filesToData(currentDir, files) {
|
||||
}
|
||||
|
||||
async function getFileData(currentDir, file) {
|
||||
const stat = await statAsync(path.join(currentDir, file));
|
||||
const stat = await fs.promises.stat(path.join(currentDir, file));
|
||||
let filesInDir = [];
|
||||
if (stat.isDirectory()) {
|
||||
filesInDir = await readdirAsync(path.join(currentDir, file));
|
||||
filesInDir = await fs.promises.readdir(path.join(currentDir, file));
|
||||
}
|
||||
const url = nconf.get('upload_url') + currentDir.replace(nconf.get('upload_path'), '') + '/' + file;
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user