@@ -73,7 +73,7 @@ t.test('should pack given directory', (t) => {
73
73
const npm = mockNpm ( {
74
74
config : {
75
75
unicode : true ,
76
- json : true ,
76
+ json : false ,
77
77
'dry-run' : true ,
78
78
} ,
79
79
output,
@@ -108,7 +108,7 @@ t.test('should pack given directory for scoped package', (t) => {
108
108
const npm = mockNpm ( {
109
109
config : {
110
110
unicode : true ,
111
- json : true ,
111
+ json : false ,
112
112
'dry-run' : true ,
113
113
} ,
114
114
output,
@@ -158,6 +158,93 @@ t.test('should log pack contents', (t) => {
158
158
} )
159
159
} )
160
160
161
+ t . test ( 'should log output as valid json' , ( t ) => {
162
+ const testDir = t . testdir ( {
163
+ 'package.json' : JSON . stringify ( {
164
+ name : 'my-cool-pkg' ,
165
+ version : '1.0.0' ,
166
+ main : './index.js' ,
167
+ } , null , 2 ) ,
168
+ 'README.md' : 'text' ,
169
+ 'index.js' : 'void' ,
170
+ } )
171
+
172
+ const Pack = t . mock ( '../../lib/pack.js' , {
173
+ libnpmpack,
174
+ '../../lib/utils/tar.js' : {
175
+ getContents : async ( ) => ( {
176
+ id :
'@ruyadorno/[email protected] ' ,
177
+ name : '@ruyadorno/redact' ,
178
+ version : '1.0.0' ,
179
+ size : 2450 ,
180
+ unpackedSize : 4911 ,
181
+ shasum : '044c7574639b923076069d6e801e2d1866430f17' ,
182
+ // mocks exactly how ssri Integrity works:
183
+ integrity : {
184
+ sha512 : [
185
+ {
186
+ source : 'sha512-JSdyskeR2qonBUaQ4vdlU/vQGSfgCxSq5O+vH+d2yVWRqzso4O3gUzd6QX/V7OWV//zU7kA5o63Zf433jUnOtQ==' ,
187
+ digest : 'JSdyskeR2qonBUaQ4vdlU/vQGSfgCxSq5O+vH+d2yVWRqzso4O3gUzd6QX/V7OWV//zU7kA5o63Zf433jUnOtQ==' ,
188
+ algorithm : 'sha512' ,
189
+ options : [ ] ,
190
+ } ,
191
+ ] ,
192
+ toJSON ( ) {
193
+ return 'sha512-JSdyskeR2qonBUaQ4vdlU/vQGSfgCxSq5O+vH+d2yVWRqzso4O3gUzd6QX/V7OWV//zU7kA5o63Zf433jUnOtQ=='
194
+ } ,
195
+ } ,
196
+ filename : '@ruyadorno/redact-1.0.0.tgz' ,
197
+ files : [
198
+ { path : 'LICENSE' , size : 1113 , mode : 420 } ,
199
+ { path : 'README.md' , size : 2639 , mode : 420 } ,
200
+ { path : 'index.js' , size : 719 , mode : 493 } ,
201
+ { path : 'package.json' , size : 440 , mode : 420 } ,
202
+ ] ,
203
+ entryCount : 4 ,
204
+ bundled : [ ] ,
205
+ } ) ,
206
+ } ,
207
+ npmlog : {
208
+ notice : ( ) => { } ,
209
+ showProgress : ( ) => { } ,
210
+ clearProgress : ( ) => { } ,
211
+ } ,
212
+ } )
213
+ const npm = mockNpm ( {
214
+ config : {
215
+ unicode : true ,
216
+ json : true ,
217
+ 'dry-run' : true ,
218
+ } ,
219
+ output,
220
+ } )
221
+ const pack = new Pack ( npm )
222
+
223
+ pack . exec ( [ testDir ] , err => {
224
+ t . error ( err , { bail : true } )
225
+
226
+ t . match ( JSON . parse ( OUTPUT ) , [ {
227
+ id :
'@ruyadorno/[email protected] ' ,
228
+ name : '@ruyadorno/redact' ,
229
+ version : '1.0.0' ,
230
+ size : 2450 ,
231
+ unpackedSize : 4911 ,
232
+ shasum : '044c7574639b923076069d6e801e2d1866430f17' ,
233
+ integrity : 'sha512-JSdyskeR2qonBUaQ4vdlU/vQGSfgCxSq5O+vH+d2yVWRqzso4O3gUzd6QX/V7OWV//zU7kA5o63Zf433jUnOtQ==' ,
234
+ filename : '@ruyadorno/redact-1.0.0.tgz' ,
235
+ files : [
236
+ { path : 'LICENSE' } ,
237
+ { path : 'README.md' } ,
238
+ { path : 'index.js' } ,
239
+ { path : 'package.json' } ,
240
+ ] ,
241
+ entryCount : 4 ,
242
+ } ] , 'pack details output as valid json' )
243
+
244
+ t . end ( )
245
+ } )
246
+ } )
247
+
161
248
t . test ( 'invalid packument' , ( t ) => {
162
249
const mockPacote = {
163
250
manifest : ( ) => {
@@ -176,7 +263,7 @@ t.test('invalid packument', (t) => {
176
263
const npm = mockNpm ( {
177
264
config : {
178
265
unicode : true ,
179
- json : true ,
266
+ json : false ,
180
267
'dry-run' : true ,
181
268
} ,
182
269
output,
0 commit comments