Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
|
||
const { execSync } = require('child_process'); | ||
const path = require('path'); | ||
const { readFileSync } = require('fs'); | ||
|
||
var assert = require('assert'); | ||
|
||
describe('Package install', function () { | ||
it('should remove non-`nodebb-` modules not specified in `install/package.json`', function () { | ||
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'); | ||
|
||
// assert it saves in package.json | ||
const packageWithExtras = JSON.parse(readFileSync(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')); | ||
assert(!packageCleaned.dependencies.dotenv, 'dependency was not removed'); | ||
}); | ||
}); |