Node.js based forum software built for the modern web
chore: use source and current local vars, + docs
Julian Lam9e4147f07c8f
diff --git a/test/package-install.js b/test/package-install.jsindex 27a7908842..0e15e145db 100644--- a/test/package-install.js+++ b/test/package-install.js@@ -7,8 +7,15 @@ const assert = require('assert');const pkgInstall = require('../src/cli/package-install');describe('Package install lib', () => {+ /**+ * Important:+ * - The tests here have a beforeEach() run prior to each test, it resets+ * package.json and install/package.json back to identical states.+ * - Update `source` and `current` for testing.+ */describe('updatePackageFile()', () => {let source;+ let current;const sourcePackagePath = path.resolve(__dirname, '../install/package.json');const packageFilePath = path.resolve(__dirname, '../package.json');@@ -23,6 +30,7 @@ describe('Package install lib', () => {await fs.copyFile(path.resolve(__dirname, '../install/package.json.bak'), sourcePackagePath);await fs.copyFile(path.resolve(__dirname, '../package.json.bak'), packageFilePath);source = JSON.parse(await fs.readFile(sourcePackagePath));+ current = JSON.parse(await fs.readFile(packageFilePath));});it('should remove non-`nodebb-` modules not specified in `install/package.json`', async () => {@@ -65,9 +73,8 @@ describe('Package install lib', () => {});it('should deep merge nested objects', async () => {- source.scripts.postinstall = 'echo "I am a silly bean";';- await fs.writeFile(packageFilePath, JSON.stringify(source, null, 4));- delete source.scripts.postinstall;+ current.scripts.postinstall = 'echo "I am a silly bean";';+ await fs.writeFile(packageFilePath, JSON.stringify(current, null, 4));source.scripts.preinstall = 'echo "What are you?";';await fs.writeFile(sourcePackagePath, JSON.stringify(source, null, 4));source.scripts.postinstall = 'echo "I am a silly bean";';