This repository was archived by the owner on Nov 15, 2018. It is now read-only.
File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,13 @@ function consoleReport (jsonReport, options) {
150
150
}
151
151
152
152
header ( '[ Unused dependencies ]' ) ;
153
- log . red ( jsonReport . unused ) ;
153
+ if ( Array . isArray ( jsonReport . unused ) ) {
154
+ jsonReport . unused . forEach ( d => {
155
+ log . red ( d . getName ( ) ) ;
156
+ } ) ;
157
+ } else {
158
+ log . red ( jsonReport . unused ) ;
159
+ }
154
160
155
161
if ( jsonReport . devDependencies . length ) {
156
162
header ( '[ Dev dependencies ]' ) ;
Original file line number Diff line number Diff line change @@ -34,6 +34,28 @@ test('should return some info', (t) => {
34
34
} ) ;
35
35
} ) ;
36
36
37
+ test ( 'should return unused Array with 1 Dep Object' , ( t ) => {
38
+ const dir = path . join ( __dirname , '../sample_project' ) ;
39
+ const options = { } ;
40
+ szero . report ( dir , options ) . then ( ( jsonReport ) => {
41
+ t . true ( jsonReport . unused , 'should have a unused object' ) ;
42
+ t . equal ( Array . isArray ( jsonReport . unused ) , true , 'should be an array' ) ;
43
+ t . equal ( jsonReport . unused [ 0 ] . getName ( ) , 'swapi-node' , 'should be an array' ) ;
44
+ t . end ( ) ;
45
+ } ) ;
46
+ } ) ;
47
+
48
+ test ( 'should return unused as string' , ( t ) => {
49
+ const dir = path . join ( __dirname , '../.' ) ;
50
+ const options = { } ;
51
+ szero . report ( dir , options ) . then ( ( jsonReport ) => {
52
+ t . true ( jsonReport . unused , 'should have a unused object' ) ;
53
+ t . equal ( Array . isArray ( jsonReport . unused ) , false , 'should be an array' ) ;
54
+ t . equal ( jsonReport . unused , 'None.' , 'should be an array' ) ;
55
+ t . end ( ) ;
56
+ } ) ;
57
+ } ) ;
58
+
37
59
test ( 'should return file info' , ( t ) => {
38
60
const dir = path . join ( __dirname , '../sample_project' ) ;
39
61
const options = { } ;
You can’t perform that action at this time.
0 commit comments