fix: use fs.promises

isekai-main
Julian Lam 3 years ago
parent 845717b8c0
commit a0a3870611

@ -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 ')
});

Loading…
Cancel
Save