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