diff --git a/install/package.json b/install/package.json index 2315dc48df..92e4bf9767 100644 --- a/install/package.json +++ b/install/package.json @@ -119,7 +119,7 @@ "ioredis": "5.3.1", "request": "2.88.2", "request-promise-native": "1.0.9", - "rimraf": "3.0.2", + "rimraf": "4.4.0", "rss": "1.2.2", "rtlcss": "4.0.0", "sanitize-html": "2.10.0", diff --git a/src/meta/css.js b/src/meta/css.js index c77520e247..3e66c78624 100644 --- a/src/meta/css.js +++ b/src/meta/css.js @@ -3,12 +3,9 @@ const winston = require('winston'); const nconf = require('nconf'); const fs = require('fs'); -const util = require('util'); const path = require('path'); const rimraf = require('rimraf'); -const rimrafAsync = util.promisify(rimraf); - const plugins = require('../plugins'); const db = require('../database'); const file = require('../file'); @@ -213,7 +210,7 @@ async function getBundleMetadata(target) { CSS.buildBundle = async function (target, fork) { if (target === 'client') { - await rimrafAsync(path.join(__dirname, '../../build/public/client*')); + await rimraf(path.join(__dirname, '../../build/public/client*'), { glob: true }); } const data = await getBundleMetadata(target); diff --git a/src/meta/js.js b/src/meta/js.js index df3fe41bae..ff5dbd6968 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -2,12 +2,9 @@ const path = require('path'); const fs = require('fs'); -const util = require('util'); const mkdirp = require('mkdirp'); const rimraf = require('rimraf'); -const rimrafAsync = util.promisify(rimraf); - const file = require('../file'); const plugins = require('../plugins'); const minifier = require('./minifier'); @@ -69,7 +66,7 @@ async function clearModules() { p => path.join(__dirname, '../../build/public/src', p) ); await Promise.all( - builtPaths.map(builtPath => rimrafAsync(builtPath)) + builtPaths.map(builtPath => rimraf(builtPath)) ); } @@ -86,7 +83,7 @@ JS.buildModules = async function () { }; JS.linkStatics = async function () { - await rimrafAsync(path.join(__dirname, '../../build/public/plugins')); + await rimraf(path.join(__dirname, '../../build/public/plugins')); await Promise.all(Object.keys(plugins.staticDirs).map(async (mappedPath) => { const sourceDir = plugins.staticDirs[mappedPath]; diff --git a/src/meta/languages.js b/src/meta/languages.js index 4d845cc2e1..1e354bef70 100644 --- a/src/meta/languages.js +++ b/src/meta/languages.js @@ -4,13 +4,9 @@ const _ = require('lodash'); const nconf = require('nconf'); const path = require('path'); const fs = require('fs'); -const util = require('util'); -let mkdirp = require('mkdirp'); - -mkdirp = mkdirp.hasOwnProperty('native') ? mkdirp : util.promisify(mkdirp); +const mkdirp = require('mkdirp'); const rimraf = require('rimraf'); -const rimrafAsync = util.promisify(rimraf); const file = require('../file'); const Plugins = require('../plugins'); @@ -137,7 +133,7 @@ async function assignFileToTranslations(translations, path) { } exports.build = async function buildLanguages() { - await rimrafAsync(buildLanguagesPath); + await rimraf(buildLanguagesPath); const data = await getTranslationMetadata(); await buildTranslations(data); }; diff --git a/src/meta/templates.js b/src/meta/templates.js index 89a68080fa..8749379bc0 100644 --- a/src/meta/templates.js +++ b/src/meta/templates.js @@ -1,9 +1,6 @@ 'use strict'; -const util = require('util'); -let mkdirp = require('mkdirp'); - -mkdirp = mkdirp.hasOwnProperty('native') ? mkdirp : util.promisify(mkdirp); +const mkdirp = require('mkdirp'); const rimraf = require('rimraf'); const winston = require('winston'); const path = require('path'); @@ -113,9 +110,7 @@ async function compileTemplate(filename, source) { Templates.compileTemplate = compileTemplate; async function compile() { - const _rimraf = util.promisify(rimraf); - - await _rimraf(viewsPath); + await rimraf(viewsPath); await mkdirp(viewsPath); let files = await plugins.getActive(); diff --git a/src/user/delete.js b/src/user/delete.js index 4a7e72dac9..d2b11e7f4d 100644 --- a/src/user/delete.js +++ b/src/user/delete.js @@ -4,8 +4,7 @@ const async = require('async'); const _ = require('lodash'); const path = require('path'); const nconf = require('nconf'); -const util = require('util'); -const rimrafAsync = util.promisify(require('rimraf')); +const rimraf = require('rimraf'); const db = require('../database'); const posts = require('../posts'); @@ -210,8 +209,8 @@ module.exports = function (User) { async function deleteImages(uid) { const folder = path.join(nconf.get('upload_path'), 'profile'); await Promise.all([ - rimrafAsync(path.join(folder, `${uid}-profilecover*`)), - rimrafAsync(path.join(folder, `${uid}-profileavatar*`)), + rimraf(path.join(folder, `${uid}-profilecover*`), { glob: true }), + rimraf(path.join(folder, `${uid}-profileavatar*`), { glob: true }), ]); } }; diff --git a/test/build.js b/test/build.js index e511761fa0..a7c060de00 100644 --- a/test/build.js +++ b/test/build.js @@ -88,11 +88,9 @@ describe('minifier', () => { describe('Build', () => { const build = require('../src/meta/build'); - before((done) => { - async.parallel([ - async.apply(rimraf, path.join(__dirname, '../build/public')), - async.apply(db.sortedSetAdd, 'plugins:active', Date.now(), 'nodebb-plugin-markdown'), - ], done); + before(async () => { + await rimraf(path.join(__dirname, '../build/public')); + await db.sortedSetAdd('plugins:active', Date.now(), 'nodebb-plugin-markdown'); }); it('should build plugin static dirs', (done) => { diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js index d22e4c01b0..10e9496919 100644 --- a/test/mocks/databasemock.js +++ b/test/mocks/databasemock.js @@ -206,7 +206,7 @@ async function setupMockDefaults() { id: 'nodebb-theme-persona', }); - const rimraf = util.promisify(require('rimraf')); + const rimraf = require('rimraf'); await rimraf('test/uploads'); const mkdirp = require('mkdirp');