mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	
		
			
	
	
		
			31 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			31 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|  | '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'); | ||
|  | 	}); | ||
|  | }); |