@@ -316,16 +316,18 @@ Map {
316316
317317 await lernaPublish ( cwd ) ( "--contents" , "dist" ) ;
318318
319- expect ( packDirectory ) . toHaveBeenCalledWith (
320- expect . objectContaining ( { name : "package-1" } ) ,
321- expect . stringContaining ( path . normalize ( "packages/package-1/dist" ) ) ,
322- expect . any ( Object )
323- ) ;
324- expect ( packDirectory ) . toHaveBeenCalledWith (
325- expect . objectContaining ( { name : "package-2" } ) ,
326- expect . stringContaining ( path . normalize ( "packages/package-2/dist" ) ) ,
327- expect . any ( Object )
328- ) ;
319+ const [ [ pkgOne , dirOne , opts ] , [ pkgTwo , dirTwo ] ] = packDirectory . mock . calls ;
320+
321+ // second argument to packDirectory() is the location, _not_ the contents
322+ expect ( dirOne ) . toBe ( pkgOne . location ) ;
323+ expect ( dirTwo ) . toBe ( pkgTwo . location ) ;
324+
325+ expect ( pkgOne . contents ) . toBe ( path . join ( pkgOne . location , "dist" ) ) ;
326+ expect ( pkgTwo . contents ) . toBe ( path . join ( pkgTwo . location , "dist" ) ) ;
327+
328+ // opts is a snapshot of npm-conf instance
329+ expect ( packDirectory ) . toHaveBeenCalledWith ( pkgOne , dirOne , opts ) ;
330+ expect ( packDirectory ) . toHaveBeenCalledWith ( pkgTwo , dirTwo , opts ) ;
329331 } ) ;
330332 } ) ;
331333
@@ -342,17 +344,24 @@ Map {
342344 await lernaPublish ( cwd ) ( ) ;
343345
344346 expect ( packDirectory ) . toHaveBeenCalledWith (
345- expect . objectContaining ( { name : "package-1" } ) ,
346- expect . stringMatching ( / p a c k a g e s [ \\ / ] + p a c k a g e - 1 [ \\ / ] + d i s t $ / ) ,
347+ expect . objectContaining ( {
348+ name : "package-1" ,
349+ contents : path . join ( cwd , "packages/package-1/dist" ) ,
350+ } ) ,
351+ path . join ( cwd , "packages/package-1" ) ,
347352 expect . any ( Object )
348353 ) ;
349354 expect ( packDirectory ) . toHaveBeenCalledWith (
350- expect . objectContaining ( { name : "package-2" } ) ,
351- expect . stringMatching ( / p a c k a g e s [ \\ / ] + p a c k a g e - 2 $ / ) ,
355+ expect . objectContaining ( {
356+ name : "package-2" ,
357+ contents : path . join ( cwd , "packages/package-2" ) ,
358+ } ) ,
359+ path . join ( cwd , "packages/package-2" ) ,
352360 expect . any ( Object )
353361 ) ;
354362 } ) ;
355363 } ) ;
364+
356365 describe ( "in a cyclical repo" , ( ) => {
357366 it ( "should throw an error with --reject-cycles" , async ( ) => {
358367 expect . assertions ( 1 ) ;
0 commit comments