forked from davglass/license-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request davglass#172 from fzaninotto/exclude-packages
Add an excludePackages option
- Loading branch information
Showing
6 changed files
with
44 additions
and
15 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
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
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 |
---|---|---|
@@ -1,23 +1,36 @@ | ||
var assert = require('assert'), | ||
path = require('path'), | ||
spawn = require('child_process').spawn, | ||
restrictedPackages = [ | ||
'readable-stream@1.1.14', | ||
'spdx-satisfies@4.0.0', | ||
'y18n@3.2.1', | ||
]; | ||
spawn = require('child_process').spawnSync; | ||
|
||
describe('bin/license-checker', function() { | ||
this.timeout(8000); | ||
|
||
it('should restrict the output to the provided packages', function(done) { | ||
var node = spawn('node', [path.join(__dirname, '../bin/license-checker'), '--json', '--packages', restrictedPackages.join(';')], { | ||
it('should restrict the output to the provided packages', function() { | ||
var restrictedPackages = [ | ||
'readable-stream@1.1.14', | ||
'spdx-satisfies@4.0.0', | ||
'y18n@3.2.1', | ||
]; | ||
var output = spawn('node', [path.join(__dirname, '../bin/license-checker'), '--json', '--packages', restrictedPackages.join(';')], { | ||
cwd: path.join(__dirname, '../'), | ||
}); | ||
|
||
assert.deepEqual(Object.keys(JSON.parse(output.stdout.toString())), restrictedPackages); | ||
}); | ||
|
||
it('should exclude provided excludedPackages from the output', function() { | ||
var excludedPackages = [ | ||
'readable-stream@1.1.14', | ||
'spdx-satisfies@4.0.0', | ||
'y18n@3.2.1', | ||
]; | ||
var output = spawn('node', [path.join(__dirname, '../bin/license-checker'), '--json', '--excludePackages', excludedPackages.join(';')], { | ||
cwd: path.join(__dirname, '../'), | ||
}); | ||
|
||
node.stdout.on('data', function(data) { | ||
assert.deepEqual(Object.keys(JSON.parse(data.toString())), restrictedPackages); | ||
done(); | ||
var packages = Object.keys(JSON.parse(output.stdout.toString())); | ||
excludedPackages.forEach(package => { | ||
assert.ok(!packages.includes(package)); | ||
}); | ||
}); | ||
}); |