Node.js based forum software built for the modern web
feat: add node 16 (#9847)
Barış Soner Uşaklıd27c9696e3d9
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yamlindex 90683cf490..e8b07af4cd 100644--- a/.github/workflows/test.yaml+++ b/.github/workflows/test.yaml@@ -21,7 +21,7 @@ jobs:fail-fast: falsematrix:os: [ubuntu-latest]- node: [12, 14]+ node: [12, 14, 16]database: [mongo-dev, mongo, redis, postgres]include:# only run coverage oncediff --git a/src/password.js b/src/password.jsindex 727528a3a8..d1b6fc2df5 100644--- a/src/password.js+++ b/src/password.js@@ -14,6 +14,10 @@ function forkChild(message, callback) {child.on('message', (msg) => {callback(msg.err ? new Error(msg.err) : null, msg.result);});+ child.on('error', (err) => {+ console.error(err.stack);+ callback(err);+ });child.send(message);}diff --git a/test/package-install.js b/test/package-install.jsindex 3305c2e532..34d256c9f4 100644--- a/test/package-install.js+++ b/test/package-install.js@@ -1,6 +1,5 @@'use strict';-const { execSync } = require('child_process');const path = require('path');const { readFileSync } = require('fs');@@ -9,12 +8,14 @@ const assert = require('assert');describe('Package install', () => {it('should remove non-`nodebb-` modules not specified in `install/package.json`', () => {+ const oldValue = process.env.NODE_ENV;+ process.env.NODE_ENV = 'development';const packageFilePath = path.join(__dirname, '../package.json');// install an extra package// chose dotenv because it's a popular package// and we use nconf instead- execSync('npm install dotenv --save --production');+ execSync('npm install dotenv --save');// assert it saves in package.jsonconst packageWithExtras = JSON.parse(readFileSync(packageFilePath, 'utf8'));@@ -26,5 +27,6 @@ describe('Package install', () => {// assert it removed the extra packageconst packageCleaned = JSON.parse(readFileSync(packageFilePath, 'utf8'));assert(!packageCleaned.dependencies.dotenv, 'dependency was not removed');+ process.env.NODE_ENV = oldValue;});});diff --git a/test/plugins.js b/test/plugins.jsindex ae5e403abf..04465896f8 100644--- a/test/plugins.js+++ b/test/plugins.js@@ -1,7 +1,6 @@'use strict';--const assert = require('assert');+const assert = require('assert');const path = require('path');const nconf = require('nconf');const request = require('request');@@ -47,7 +46,7 @@ describe('Plugins', () => {});});- it('should register and fire a filter hook having 3 methods, one returning a promise, one calling the callback and one just returning', async () => {+ it('should register and fire a filter hook having 3 methods', async () => {function method1(data, callback) {data.foo += 1;callback(null, data);@@ -214,6 +213,16 @@ describe('Plugins', () => {describe('install/activate/uninstall', () => {let latest;const pluginName = 'nodebb-plugin-imgur';+ const oldValue = process.env.NODE_ENV;+ before((done) => {+ process.env.NODE_ENV = 'development';+ done();+ });+ after((done) => {+ process.env.NODE_ENV = oldValue;+ done();+ });+it('should install a plugin', function (done) {this.timeout(0);plugins.toggleInstall(pluginName, '1.0.16', (err, pluginData) => {@@ -284,7 +293,8 @@ describe('Plugins', () => {});it('should 404 if resource does not exist', (done) => {- request.get(`${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/should404.tpl`, (err, res, body) => {+ const url = `${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/should404.tpl`;+ request.get(url, (err, res, body) => {assert.ifError(err);assert.equal(res.statusCode, 404);assert(body);@@ -293,7 +303,8 @@ describe('Plugins', () => {});it('should get resource', (done) => {- request.get(`${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/dbsearch.tpl`, (err, res, body) => {+ const url = `${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/dbsearch.tpl`;+ request.get(url, (err, res, body) => {assert.ifError(err);assert.equal(res.statusCode, 200);assert(body);@@ -302,3 +313,5 @@ describe('Plugins', () => {});});});++diff --git a/test/socket.io.js b/test/socket.io.jsindex b707de09a0..fad6591185 100644--- a/test/socket.io.js+++ b/test/socket.io.js@@ -106,7 +106,12 @@ describe('socket.io', () => {});it('should post a topic', (done) => {- io.emit('topics.post', { title: 'test topic title', content: 'test topic main post content', uid: adminUid, cid: cid }, (err, result) => {+ io.emit('topics.post', {+ title: 'test topic title',+ content: 'test topic main post content',+ uid: adminUid,+ cid: cid,+ }, (err, result) => {assert.ifError(err);assert.equal(result.user.username, 'admin');assert.equal(result.category.cid, cid);@@ -473,9 +478,17 @@ describe('socket.io', () => {it('should toggle plugin install', function (done) {this.timeout(0);- socketAdmin.plugins.toggleInstall({ uid: adminUid }, { id: 'nodebb-plugin-location-to-map', version: 'latest' }, (err, data) => {+ const oldValue = process.env.NODE_ENV;+ process.env.NODE_ENV = 'development';+ socketAdmin.plugins.toggleInstall({+ uid: adminUid,+ }, {+ id: 'nodebb-plugin-location-to-map',+ version: 'latest',+ }, (err, data) => {assert.ifError(err);assert.equal(data.name, 'nodebb-plugin-location-to-map');+ process.env.NODE_ENV = oldValue;done();});});@@ -507,8 +520,16 @@ describe('socket.io', () => {it('should upgrade plugin', function (done) {this.timeout(0);- socketAdmin.plugins.upgrade({ uid: adminUid }, { id: 'nodebb-plugin-location-to-map', version: 'latest' }, (err) => {+ const oldValue = process.env.NODE_ENV;+ process.env.NODE_ENV = 'development';+ socketAdmin.plugins.upgrade({+ uid: adminUid,+ }, {+ id: 'nodebb-plugin-location-to-map',+ version: 'latest',+ }, (err) => {assert.ifError(err);+ process.env.NODE_ENV = oldValue;done();});});@@ -521,7 +542,13 @@ describe('socket.io', () => {});it('should error with invalid data', (done) => {- const data = [{ template: 'global', location: 'sidebar', widgets: [{ widget: 'html', data: { html: 'test', title: 'test', container: '' } }] }];+ const data = [+ {+ template: 'global',+ location: 'sidebar',+ widgets: [{ widget: 'html', data: { html: 'test', title: 'test', container: '' } }],+ },+ ];socketAdmin.widgets.set({ uid: adminUid }, data, (err) => {assert.ifError(err);db.getObjectField('widgets:global', 'sidebar', (err, widgetData) => {