11const t = require ( 'tap' )
2+ const { basename, join, posix } = require ( 'path' )
3+ const fs = require ( 'fs' )
24
35const rpj = require ( '../' )
46
7+ const joinValues = ( obj ) =>
8+ Object . fromEntries ( Object . entries ( obj ) . map ( ( [ k , v ] ) => [ k , join ( ...v . split ( posix . sep ) ) ] ) )
9+
510t . test ( 'errors for bad/missing data' , async t => {
611 t . test ( 'raises an error for missing file' , t =>
712 t . rejects ( rpj ( t . testdir ( ) + '/package.json' ) , { code : 'ENOENT' } ) )
@@ -12,7 +17,7 @@ t.test('errors for bad/missing data', async t => {
1217 } ) + '/package.json' ) , { code : 'EJSONPARSE' } ) )
1318} )
1419
15- t . test ( 'clean up bundleddddddDependencies ' , async t => {
20+ t . test ( 'clean up bundleDependencies ' , async t => {
1621 t . test ( 'change name if bundleDependencies is not present' , t =>
1722 t . resolveMatch ( rpj ( t . testdir ( {
1823 'package.json' : JSON . stringify ( { bundledDependencies : [ ] } ) ,
@@ -275,8 +280,6 @@ t.test('strip _fields', async t => {
275280} )
276281
277282t . test ( 'load directories.bin' , async t => {
278- const { basename } = require ( 'path' )
279- const fs = require ( 'fs' )
280283 const rpjMock = t . mock ( '../' , {
281284 fs : {
282285 ...fs ,
@@ -331,12 +334,12 @@ t.test('load directories.bin', async t => {
331334 directories : {
332335 bin : 'bin' ,
333336 } ,
334- bin : {
337+ bin : joinValues ( {
335338 foo : 'bin/foo' ,
336339 bar : 'bin/bar' ,
337340 a : 'bin/subdir/a' ,
338341 b : 'bin/subdir/b' ,
339342 suba : 'bin/subdir/sub/suba' ,
340- } ,
343+ } ) ,
341344 } )
342345} )
0 commit comments