mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: use fs.promises
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const path = require('path');
|
||||
const { readFileSync } = require('fs');
|
||||
const { readFile } = require('fs').promises;
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
describe('Package install', () => {
|
||||
it('should remove non-`nodebb-` modules not specified in `install/package.json`', () => {
|
||||
it('should remove non-`nodebb-` modules not specified in `install/package.json`', async () => {
|
||||
const oldValue = process.env.NODE_ENV;
|
||||
process.env.NODE_ENV = 'development';
|
||||
const packageFilePath = path.join(__dirname, '../package.json');
|
||||
@@ -18,15 +18,17 @@ describe('Package install', () => {
|
||||
execSync('npm install dotenv --save');
|
||||
|
||||
// assert it saves in package.json
|
||||
const packageWithExtras = JSON.parse(readFileSync(packageFilePath, 'utf8'));
|
||||
const packageWithExtras = JSON.parse(await readFile(packageFilePath, 'utf8'));
|
||||
assert(packageWithExtras.dependencies.dotenv, 'dependency did not save');
|
||||
|
||||
// update the package file
|
||||
require('../src/cli/package-install').updatePackageFile();
|
||||
|
||||
// assert it removed the extra package
|
||||
const packageCleaned = JSON.parse(readFileSync(packageFilePath, 'utf8'));
|
||||
const packageCleaned = JSON.parse(await readFile(packageFilePath, 'utf8'));
|
||||
assert(!packageCleaned.dependencies.dotenv, 'dependency was not removed');
|
||||
process.env.NODE_ENV = oldValue;
|
||||
});
|
||||
|
||||
// it('should ')
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user